Convert a date in Gregorian calendar to Lunar calendar.
This repo does not do any calculations regarding the calendars. Instead it just tells the HuggingFace Space hnthap/am-lich-viet-nam to calculate the calendar conversion and send it back via Gradio Client.
I created this repo to demonstrate how to create a backend for any HuggingFace Spaces.
Create a file named .env in the repository's root directory with the following contents:
# Replace the values with your desired host name and port
HOSTNAME=localhost
PORT=8080Create a Python virtual enviroment:
python -m venv env
./env/Scripts/activate # Or: source ./env/bin/activateActivate the virtual environment, then run:
pip install -r requirements.txtTo start the server, run:
python app.pyGET /api/{tz}/{year}/{month}/{day}where
tzis the time zone offset from UTC in hoursyearis the year (Gregorian calendar)monthis the month (Gregorian calendar) with January is 1, February is 2, and so on.dayis the day of month (Gregorian calendar) that starts from 1.
For example:
GET /api/7/2024/10/1yields the following result:
{
"time_zone_hours": 7,
"Gregorian": "2024-10-01",
"lunar": {
"year": 2024,
"month": 8,
"day": 29,
"leap_month": false,
"month_size": 30,
"international": "2024-08-29 (30-day month)",
"vi": "ngày 29 tháng Tám (đủ) năm Giáp Thìn",
"zh": "甲辰年八月(大)廿九日",
"emoji": "🌑"
}
}