Persian calendar library, now in Go
Looking in the rearview mirror
Back in 2005, I released a set controls and date libraries to work with dates, in particular Solar Hijri Calendar (a.k.a Persian calendar).
To quote from Wikipedia:
The Solar Hijri calendar is one of the oldest calendars in the world, as well as the most accurate solar calendar in use today.
The calendar is in use in many countries such as Iran, Afghanistan, Tajikstan (with minor differences in month names).
The library called FarsiLibrary and was originally built on top of .NET Framework 1.1 and then ported to .NET Framework 2.0, which lacked official solar hijro calendar support. The library was published as an article on CodeProject and was a great hit. The Right-To-Left controls were not a common place and the lack of calendar and date calculation was an impediment to multi-cultural business application. In late 2006/early 2007 WPF was the new cool kid around the block, so as a way to learn, I ported my controls over and subsequently published a new set of controls. This was published as another article on Code Project.
Throughout this process, one thing was a common denominator: I leared a lot as I was working on it.
Now, after more than a decade, I have re-written the library, this time in GoLang as a way to help brush up on my Go. The first initial version can be found on my Github repository and will be officially in the following weeks.
Date Functions
Two way date conversions are now possible, using time.Time
and PersianDate
structs:
1 | import ( |
The PersianDate
struct implements Stringer interface as well as json marshal/unmarshal interfaces, so you can use it accordingly:
1 | func Serialize() { |
Formatting
Other formatting functions are also available throught the Format()
function.
1 | pd, err := date.Parse("1388/02/30") |
Note that these string use the persian numerals. Other formats also exist that return arabic numerals:
1 | pd.Format("S") // returns serializable format "1388-02-03" |
Summary
The Go version of the FarsiLibrary is here! It is built on the trusted and matured .NET version of the library. Feel free to drop a comment if you have any comments/feedbacks.