Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hzamani/parsi-date
Solar Hijri (Jalali, Persian) date library for Ruby
https://github.com/hzamani/parsi-date
Last synced: 10 days ago
JSON representation
Solar Hijri (Jalali, Persian) date library for Ruby
- Host: GitHub
- URL: https://github.com/hzamani/parsi-date
- Owner: hzamani
- License: mit
- Created: 2012-10-27T10:22:00.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-06-23T02:05:15.000Z (14 days ago)
- Last Synced: 2024-06-24T04:55:34.932Z (13 days ago)
- Language: Ruby
- Homepage:
- Size: 73.2 KB
- Stars: 45
- Watchers: 6
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Lists
- awesome-persian - parsi-date - Solar Hijri (Jalali, Persian) date library for Ruby. (Jalali Date)
- awesome-hijri - Parsi Date - هجري شمسي للغة روبي. (أدوات للمطورين / روبي Ruby)
README
= Parsi Date
This is an implementation of {Solar Hijri Calendar}[http://en.wikipedia.org/wiki/Solar_Hijri_calendar]
(some times referred to as Jalali or Persian Calendar) which is Iran's official calendar.
Main aim of this gem is to create a Solar Hijri date library as close as possible to the built-in date library.
Conversion algorithm originally adopted from {here}[http://www.fourmilab.ch/documents/calendar/].== Usage
You can use Parsi::Date<\tt> and Parsi::DateTime<\tt> objects as +Date+ and +DateTime+ objects
For example:a = Parsi::Date.today # => #
b = a >> 12 # => #
a.upto(b).select{ |d| d.sunday? }.count # => 52Parsi::Date.leap? 1391 # => true
c = Parsi::Date.parse "1391/10/12" # => #
c.strftime "%A %d %B %Y" # => "سهشنبه 12 دی 1391"
c.strftime "%^EA %d %^EB %Y" # => "Seshambe 12 Day 1391"For converting a +Date+ or +DateTime+ object just call +to_parsi+ (aliased to +jalali+ and +to_jalali+) on it.
To convert back use +to_gregorian+.d = Date.civil(2012, 10, 30).to_parsi # => #
d.to_gregorian # => #Copyright (c) 2012 Hassan Zamani, released under the MIT license.