Repository navigation
Home
Amir Iranmanesh edited this page Aug 11, 2026
·
3 revisions
ptime is a complete, dependency-free Persian (Solar Hijri / Jalali) calendar for Go, shaped like the standard time package.
go get github.com/amiranmanesh/go-persian-calendarimport ptime "github.com/amiranmanesh/go-persian-calendar"
pt := ptime.Now()
fmt.Println(pt.Format("yyyy/MM/dd E"))| Page | What it covers |
|---|---|
| Getting Started | Installing, converting in both directions, the shape of Time
|
| Formatting | Both layout languages, every pattern letter, the predefined layouts |
| Parsing |
Parse, locations, two digit years, error handling |
| Encoding | JSON, text, and SQL Value/Scan
|
| Calendar Helpers | Leap years, weeks, first and last days, day parts |
| Public Holidays | The holiday package, why lunar dates are estimates, keeping data current |
| Migration | Moving from yaa110/go-persian-calendar
|
| FAQ | Time zones, leap year rules, thread safety, performance |
The generated API reference for every exported identifier lives on pkg.go.dev. This wiki is for the parts that need more than a doc comment.
Every conversion passes through the Julian Day Number, a continuous count of days that belongs to no calendar:
Persian date ⟷ JDN ⟷ Gregorian date
Going through a neutral representation costs one extra step and buys exactness across the 1582 Gregorian reform: dates before it are interpreted in the Julian calendar, dates on or after it in the Gregorian calendar, and the package picks the right formula for you.
-
Timeis a value. Methods with a value receiver return a newTime; nothing is mutated behind your back. Copy it freely. -
Names track the standard library. If
timehas a method for the idea,ptimeuses the same name, signature and semantics —Add,AddDate,Sub,Before,After,Equal,Compare,Truncate,Round,Unix,In. - No dependencies. Only the standard library, and no I/O beyond loading time zone data.
MIT licensed · Source · pkg.go.dev · Site