{"id":13412462,"url":"https://github.com/yaa110/go-persian-calendar","last_synced_at":"2025-04-05T08:08:26.399Z","repository":{"id":46009465,"uuid":"50789028","full_name":"yaa110/go-persian-calendar","owner":"yaa110","description":"The implementation of Persian (Solar Hijri) Calendar in Go","archived":false,"fork":false,"pushed_at":"2024-08-17T13:37:01.000Z","size":115,"stargazers_count":205,"open_issues_count":6,"forks_count":26,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-25T04:10:05.062Z","etag":null,"topics":["go","golang","golang-module","jalali","persian-calendar"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/yaa110/go-persian-calendar","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaa110.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-31T18:40:23.000Z","updated_at":"2024-10-09T10:16:00.000Z","dependencies_parsed_at":"2024-10-24T16:13:47.670Z","dependency_job_id":null,"html_url":"https://github.com/yaa110/go-persian-calendar","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Fgo-persian-calendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Fgo-persian-calendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Fgo-persian-calendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaa110%2Fgo-persian-calendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaa110","download_url":"https://codeload.github.com/yaa110/go-persian-calendar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","golang-module","jalali","persian-calendar"],"created_at":"2024-07-30T20:01:24.950Z","updated_at":"2025-04-05T08:08:26.374Z","avatar_url":"https://github.com/yaa110.png","language":"Go","funding_links":[],"categories":["Date and Time","Jalali Date","日期和时间","\u003cspan id=\"日期和时间-date-and-time\"\u003e日期和时间 Date and Time\u003c/span\u003e","日期和时间`用于处理日期和时间的库`","Relational Databases","Date \u0026 Time"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","SQL 查询语句构建库"],"readme":"# Go Persian Calendar\n\n[![godoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://pkg.go.dev/github.com/yaa110/go-persian-calendar) [![Test and Build](https://github.com/yaa110/go-persian-calendar/workflows/Test%20and%20Build/badge.svg)](https://github.com/yaa110/go-persian-calendar/actions?query=workflow%3A\"Test+and+Build\") [![goreportcard](https://img.shields.io/badge/go%20report-A%2B-brightgreen.svg)](http://goreportcard.com/report/yaa110/go-persian-calendar) [![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/yaa110/go-persian-calendar/blob/master/LICENSE)\n\n**Go Persian Calendar** provides functionality for conversion among Persian (Solar Hijri) and Gregorian calendars. A Julian calendar is used as an interface for all conversions. The package name is `ptime` and it is compatible with the package [time](https://golang.org/pkg/time). All months are available with both Iranian and Dari Persian names. This source code is licensed under MIT license that can be found in the LICENSE file.\n\n## Installation\n\n```bash\ngo get github.com/yaa110/go-persian-calendar\n```\n\n## Getting started\n\n1- Import the package `ptime`. Most of the time you need to import `time` and `fmt` packages, too.\n\n```go\nimport (\n    ptime \"github.com/yaa110/go-persian-calendar\"\n    \"time\"\n    \"fmt\"\n)\n```\n\n2- Convert Gregorian calendar to Persian calendar.\n\n```go\n// Create a new instance of time.Time\nvar t time.Time = time.Date(2016, time.January, 1, 12, 1, 1, 0, ptime.Iran())\n\n// Get a new instance of ptime.Time using time.Time\npt := ptime.New(t)\n\n// Get the date in Persian calendar\nfmt.Println(pt.Date()) // output: 1394 دی 11\n```\n\n3- Convert Persian calendar to Gregorian calendar.\n\n```go\n// Create a new instance of ptime.Time\nvar pt ptime.Time = ptime.Date(1394, ptime.Mehr, 2, 12, 59, 59, 0, ptime.Iran())\n\n// Get a new instance of time.Time\nt := pt.Time()\n\n// Get the date in Gregorian calendar\nfmt.Println(t.Date()) // output: 2015 September 24\n```\n\n4- Get the current time.\n\n```go\n// Get a new instance of ptime.Time representing the current time\npt := ptime.Now()\n\n// Get year, month, day\nfmt.Println(pt.Date()) // output: 1394 بهمن 11\nfmt.Println(pt.Year(), pt.Month(), pt.Day()) // output: 1394 بهمن 11\n\n// Get hour, minute, second\nfmt.Println(pt.Clock()) // output: 21 54 30\nfmt.Println(pt.Hour(), pt.Minute(), pt.Second()) // output: 21 54 30\n\n// Get Unix timestamp (the number of seconds since January 1, 1970 UTC)\nfmt.Println(pt.Unix()) // output: 1454277270\n\n// Get yesterday, today and tomorrow\nfmt.Println(pt.Yesterday().Weekday()) // output: شنبه\nfmt.Println(pt.Weekday()) // output: یک‌شنبه\nfmt.Println(pt.Tomorrow().Weekday()) // output: دوشنبه\n\n// Get First and last day of week\nfmt.Println(pt.FirstWeekDay().Date()) // output: 1394 بهمن 10\nfmt.Println(pt.LastWeekday().Date()) // output: 1394 بهمن 16\n\n// Get First and last day of month\nfmt.Println(pt.FirstMonthDay().Weekday()) // output: پنج‌شنبه\nfmt.Println(pt.LastMonthDay().Weekday()) // output: جمعه\n\n// Get First and last day of year\nfmt.Println(pt.FirstYearDay().Weekday()) // output: شنبه\nfmt.Println(pt.LastYearDay().Weekday()) // output: شنبه\n\n// Get the week of month\nfmt.Println(pt.MonthWeek()) // output: 3\n\n// Get the week of year\nfmt.Println(pt.YearWeek()) // output: 46\n\n// Get the number of remaining weeks of the year\nfmt.Println(pt.RYearWeek()) // output: 6\n```\n\n5- Format the time.\n\n```go\n// Get a new instance of ptime.Time using Unix timestamp\npt := ptime.Unix(1454277270, 0)\n\nfmt.Println(pt.Format(\"yyyy/MM/dd E hh:mm:ss a\")) // output: 1394/11/11 یک‌شنبه 09:54:30 ب.ظ\n\n// yyyy, yyy, y     year (e.g. 1394)\n// yy               2-digits representation of year (e.g. 94)\n// MMM              the Persian name of month (e.g. فروردین)\n// MMI              the Dari name of month (e.g. حمل)\n// MM               2-digits representation of month (e.g. 01)\n// M                month (e.g. 1)\n// rw               remaining weeks of year\n// w                week of year\n// W                week of month\n// RD               remaining days of year\n// D                day of year\n// rd               remaining days of month\n// dd               2-digits representation of day (e.g. 01)\n// d                day (e.g. 1)\n// E                the Persian name of weekday (e.g. شنبه)\n// e                the Persian short name of weekday (e.g. ش)\n// A                the Persian name of 12-Hour marker (e.g. قبل از ظهر)\n// a                the Persian short name of 12-Hour marker (e.g. ق.ظ)\n// HH               2-digits representation of hour [00-23]\n// H                hour [0-23]\n// kk               2-digits representation of hour [01-24]\n// k                hour [1-24]\n// hh               2-digits representation of hour [01-12]\n// h                hour [1-12]\n// KK               2-digits representation of hour [00-11]\n// K                hour [0-11]\n// mm               2-digits representation of minute [00-59]\n// m                minute [0-59]\n// ss               2-digits representation of seconds [00-59]\n// s                seconds [0-59]\n// ns               nanoseconds\n// S                3-digits representation of milliseconds (e.g. 001)\n// z                the name of location\n// Z                zone offset (e.g. +03:30)\n```\n\n6- Format the time using [standard format](https://golang.org/src/time/format.go).\n\n```go\npt := ptime.Date(1394, 7, 2, 14, 7, 8, 0, Iran())\n\nfmt.Println(pt.TimeFormat(\"2 Jan 2006\")) // output: 2 مهر 1394\n\n// 2006        four digit year (e.g. 1399)\n// 06          two digit year (e.g. 99)\n// 01          two digit month (e.g. 01)\n// 1           one digit month (e.g. 1)\n// Jan         month name (e.g. آذر)\n// January     month name (e.g. آذر)\n// 02          two digit day (e.g. 07)\n// 2           one digit day (e.g. 7)\n// _2          right justified two character day (e.g.  7)\n// Mon         weekday (e.g. شنبه)\n// Monday      weekday (e.g. شنبه)\n// 03          two digit 12 hour format (e.g. 03)\n// 3           one digit 12 hour format (e.g. 3)\n// 15          two digit 24 hour format (e.g. 15)\n// 04          two digit minute (e.g. 03)\n// 4           one digit minute (e.g. 03)\n// 05          two digit minute (e.g. 09)\n// 5           one digit minute (e.g. 9)\n// .000        millisecond (e.g. .120)\n// .000000     microsecond (e.g. .123400)\n// .000000000  nanosecond (e.g. .123456000)\n// .999        trailing zeros removed millisecond (e.g. .12)\n// .999999     trailing zeros removed microsecond (e.g. .1234)\n// .999999999  trailing zeros removed nanosecond (e.g. .123456)\n// PM          full 12-Hour marker (e.g. قبل از ظهر)\n// pm          short 12-Hour marker (e.g. ق.ظ)\n// MST         the name of location\n// -0700       zone offset (e.g. +0330)\n// -07         zone offset (e.g. +03)\n// -07:00      zone offset (e.g. +03:30)\n// Z0700       zone offset (e.g. +0330)\n// Z07:00      zone offset (e.g. +03:30)\n```\n\n## Limitations\n\n- The minimum value of Gregorian year is 1097, otherwise a zero instance of `ptime.Time` is returned.\n\n## Documentation\n\nPlease read [the documentation](https://pkg.go.dev/github.com/yaa110/go-persian-calendar) for more information about methods and functionality available for `ptime.Time`, `ptime.Month`, `ptime.Weekday` and `ptime.AmPm`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaa110%2Fgo-persian-calendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaa110%2Fgo-persian-calendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaa110%2Fgo-persian-calendar/lists"}