Sha256: a4b4cf218b47dd6545a2373148ac74144c47c949294d23634c0008d73163b4e9
Contents?: true
Size: 647 Bytes
Versions: 2
Compression:
Stored size: 647 Bytes
Contents
class Date def to_hijri Hijri::Hijri.new *Hijri::Converter.greo_to_hijri(self) end def last_day_of_gregorian_month(month) # Compute the last date of the month for the Gregorian calendar. if month == 2 return 29 if (self.year % 4 == 0 && self.year % 100 != 0) || (self.year % 400 == 0) end return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1] end def to_abs @d = self.day @m = self.month - 1 @m.downto(1) do |m| @d += last_day_of_gregorian_month(@m, year) end return (@d + 365 * (year - 1) + (year -1) / 4.0 - (year - 1) / 100.0 + (year - 1) / 400.0).to_i end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hijri-0.0.5 | lib/hijri/date.rb |
hijri-0.0.1 | lib/hijri/date.rb |