Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gmain #5

Merged
merged 4 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 92 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<p align="center">
<img src="internal/assets/logo_medium.png" alt="logo" width="110" height="110">
</p>
<h1 align="center"><a href="https://pkg.go.dev/gitlab.com/Yinebeb-01/ethiopiandateconverter">Ethiopian Date Converter</a></h1>
<h1 align="center"><a href="https://pkg.go.dev/gitlab.com/Yinebeb-01/ethiopiancalendar">Ethiopian Calendar (ባሕረ-ሐሳብ)</a></h1>

## Description
The Ethiopian Date Converter API is designed to facilitate the conversion between Ethiopian dates
(in the format yy-mm-dd) and Gregorian dates. Ethiopia follows its own calendar system, which consists of 13 months,
each with 30 days.
The Ethiopian calendar(ባሕረ-ሀሳብ) is used to get Fasting and Holiday's specific date with in a year based on
[EOTC](https://www.ethiopianorthodox.org/) calendar. It also designed to facilitate the conversion between Ethiopian dates (in the format yy-mm-dd) and
Gregorian dates. Ethiopia follows its own calendar system, which consists of 13 months, each with 30 days.

### Functionality
This API allows users to:
* Fetching all festivals with a year such as year, Basic data and Fasting dates.
* Convert Ethiopian dates to Gregorian dates.
* Convert Gregorian dates to Ethiopian dates.

### Usage
To utilize the API, simply send a date using the specified endpoints. The API will respond with the converted date
in JSON format.
To utilize the API, simply send a date or year using the specified endpoints. For the date conversion,the API will
respond with the converted date in JSON format whereas for the calendar, it will respond data in a json object.

#### Example Usage

Expand Down Expand Up @@ -64,13 +65,95 @@ Response:
}
```

## Installation
3. Get Ethiopian Calendar such as Holidays and Fasting dates.

```curl
GET /bahire-hasab/{year}
```

* Parameters:

`year:` The Ethiopian year.

**Example**:

```curl
GET /bahire-hasab/2016
```

Response:

```json
{
"data": {
"year": {
"year":2016,
"evangelist_num":0,
"evangelist":"ዮሐንስ(John)",
"day_of_the_week":"ማክሰኞ(Tuesday)"
},
"basic": {
"medeb":11,
"wenber":10,
"abektie":20,
"metiq":10,
"beale_metiq":2,
"mebaja_hamer":18,
"nenewie":{
"DateOfTheMonth":18,
"MonthOfTheYear":6
}
},
"fasting":{
"abiy":{
"DateOfTheMonth":2,
"MonthOfTheYear":7
},
"debrezeit":{
"DateOfTheMonth":29,
"MonthOfTheYear":7
},
"hosanna":{
"DateOfTheMonth":20,
"MonthOfTheYear":8
},
"siklet":{
"DateOfTheMonth":25,
"MonthOfTheYear":8
},
"tinsaye":{
"DateOfTheMonth":27,
"MonthOfTheYear":8
},
"rkbekahnat":{
"DateOfTheMonth":21,
"MonthOfTheYear":9
},
"dihnet":{
"DateOfTheMonth":19,
"MonthOfTheYear":10
},
"hawariyat":{
"DateOfTheMonth":17,
"MonthOfTheYear":10
},
"erget":{
"DateOfTheMonth":6,
"MonthOfTheYear":10},
"peraklitos":{
"DateOfTheMonth":16,
"MonthOfTheYear":10
}
}
}
}
```

## Installation
Install using below go command:
```bash
go get gitlab.com/Yinebeb-01/ethiopiandateconverter
```

## Author
- [Yinebeb T.](https://github.com/Yinebeb-01/)
- [python version](https://github.com/dimagi/ethiopian-date-converter)
- [Yinebeb T.](https://github.com/Yinebeb-01/)
13 changes: 7 additions & 6 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Copyright (c) 2022 Yinebeb Tariku <yintar5@gmail.com>
package main

import (
"github.com/Yinebeb-01/ethiopiandateconverter/config"
"github.com/Yinebeb-01/ethiopiandateconverter/docs"
"github.com/Yinebeb-01/ethiopiandateconverter/internal/api"
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"gitlab.com/Yinebeb-01/ethiopiancalendar/config"
docs "gitlab.com/Yinebeb-01/ethiopiancalendar/docs"
api2 "gitlab.com/Yinebeb-01/ethiopiancalendar/internal/api"
)

// @title EthioGrego
Expand All @@ -37,9 +37,10 @@ func main() {
router.StaticFile("favicon.ico", "internal/assets/favicon.ico")
v1 := router.Group(docs.SwaggerInfo.BasePath)
{
v1.GET("", api.HomePage)
v1.GET("/et-to-ad/:date", api.Gregorian)
v1.GET("/ad-to-et/:date", api.Ethiopian)
v1.GET("", api2.HomePage)
v1.GET("/et-to-ad/:date", api2.Gregorian)
v1.GET("/ad-to-et/:date", api2.Ethiopian)
v1.GET("/bahire-hasab/:year", api2.BahireHasab)

router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}
Expand Down
214 changes: 214 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,50 @@ const docTemplate = `{
}
}
},
"/bahire-hasab/{year}": {
"get": {
"description": "Get years fasting and festival date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Bahirehasab"
],
"summary": "Bahirehasab (ባህረ-ሐሳብ)",
"parameters": [
{
"type": "string",
"description": "year",
"name": "year",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/bahirehasab.Festival"
}
},
"400": {
"description": "Bad Request",
"schema": {}
},
"404": {
"description": "Not Found",
"schema": {}
},
"500": {
"description": "Internal Server Error",
"schema": {}
}
}
}
},
"/et-to-ad/{date}": {
"get": {
"description": "Get gregorian date string from ethiopian date",
Expand Down Expand Up @@ -146,6 +190,176 @@ const docTemplate = `{
}
}
},
"definitions": {
"bahirehasab.Basic": {
"type": "object",
"properties": {
"abektie": {
"description": "Abekti (አበቅቴ)",
"type": "integer"
},
"beale_metiq": {
"description": "BealeMetiq (በዓለ-መጥቅ), 1 =መስከረም፣ 2 = ጥቅምት",
"type": "integer"
},
"mebaja_hamer": {
"description": "MebajaHamer (መባጃ ሃመር)",
"type": "integer"
},
"medeb": {
"description": "Medeb (መደብ)",
"type": "integer"
},
"metiq": {
"description": "Metiq (መጥቅ)",
"type": "integer"
},
"nenewie": {
"description": "Nenewie የነነዌ ፆም የሚውልበት ቀን",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"wenber": {
"description": "Wenber (ወንበር)",
"type": "integer"
}
}
},
"bahirehasab.Date": {
"type": "object",
"properties": {
"dateOfTheMonth": {
"type": "integer"
},
"monthOfTheYear": {
"type": "integer"
}
}
},
"bahirehasab.Fasting": {
"type": "object",
"properties": {
"abiy": {
"description": "Abiy tsome (አብይ ፆም)",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"debrezeit": {
"description": "DebreZeit ደብረ ዘይት",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"dihnet": {
"description": "Dihnet (ፆመ ድህነት), Wednesday and Friday Weekly fast",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"erget": {
"description": "Erget (እርገት)፣ Ascension",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"hawariyat": {
"description": "Hawariyat ( ፆመ ሐዋሪያት), fast of the Holy Apostles",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"hosanna": {
"description": "Hosanna ሆሳህና",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"peraklitos": {
"description": "Peraklitos (ጰራቅሊጦስ)፣ Paraclete",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"rkbekahnat": {
"description": "RkbeKahnat (ርክበ ካህናት)",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"siklet": {
"description": "Siklet (ስቅለት), Good Friday",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
},
"tinsaye": {
"description": "Tinsaye (ፋሲካ), resurrection",
"allOf": [
{
"$ref": "#/definitions/bahirehasab.Date"
}
]
}
}
},
"bahirehasab.Festival": {
"type": "object",
"properties": {
"basic": {
"$ref": "#/definitions/bahirehasab.Basic"
},
"fasting": {
"$ref": "#/definitions/bahirehasab.Fasting"
},
"year": {
"$ref": "#/definitions/bahirehasab.Year"
}
}
},
"bahirehasab.Year": {
"type": "object",
"properties": {
"day_of_the_week": {
"description": "DayOfTheWeek the day in which new year fall",
"type": "string"
},
"evangelist": {
"description": "Evangelist ወንጌላዊው in name",
"type": "string"
},
"evangelist_num": {
"description": "EvangelistNum (Evangelist) ወንጌላዊው in number",
"type": "integer"
},
"year": {
"description": "Year in Ethiopian calendar",
"type": "integer"
}
}
}
},
"securityDefinitions": {
"BasicAuth": {
"type": "basic"
Expand Down
Loading
Loading