Class: Hijri::DateTime
Constant Summary
Constants inherited from Date
Hijri::Date::DAYNAMES, Hijri::Date::MONTHNAMES_EN
Instance Attribute Summary collapse
-
#hour ⇒ Object
readonly
Returns the value of attribute hour.
-
#minute ⇒ Object
readonly
Returns the value of attribute minute.
-
#second ⇒ Object
readonly
Returns the value of attribute second.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Attributes inherited from Date
Class Method Summary collapse
Instance Method Summary collapse
- #change(kargs) ⇒ Object
-
#initialize(year = 1, month = 1, day = 1, hour = 0, minute = 0, second = 0, zone = "00:00") ⇒ DateTime
constructor
A new instance of DateTime.
- #to_greo ⇒ Object
Methods inherited from Date
#islamic_leap_year?, #last_day_of_islamic_month, #to_abs, #to_s, today
Constructor Details
#initialize(year = 1, month = 1, day = 1, hour = 0, minute = 0, second = 0, zone = "00:00") ⇒ DateTime
Returns a new instance of DateTime.
5 6 7 8 9 10 11 |
# File 'lib/hijri/datetime.rb', line 5 def initialize(year=1, month=1, day=1, hour=0, minute=0, second=0, zone="00:00") super(year, month, day) @hour = hour @minute = minute @second = second @zone = zone end |
Instance Attribute Details
#hour ⇒ Object (readonly)
Returns the value of attribute hour.
4 5 6 |
# File 'lib/hijri/datetime.rb', line 4 def hour @hour end |
#minute ⇒ Object (readonly)
Returns the value of attribute minute.
4 5 6 |
# File 'lib/hijri/datetime.rb', line 4 def minute @minute end |
#second ⇒ Object (readonly)
Returns the value of attribute second.
4 5 6 |
# File 'lib/hijri/datetime.rb', line 4 def second @second end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
4 5 6 |
# File 'lib/hijri/datetime.rb', line 4 def zone @zone end |
Class Method Details
.now ⇒ Object
27 28 29 30 31 32 |
# File 'lib/hijri/datetime.rb', line 27 def now datetime = ::DateTime.now hijri = datetime.to_hijri hijri.change :hour => datetime.hour, :minute => datetime.minute, :second => datetime.second hijri end |
Instance Method Details
#change(kargs) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/hijri/datetime.rb', line 13 def change(kargs) @hour = kargs.fetch :hour, hour @minute = kargs.fetch :minute, minute @second = kargs.fetch :second, second @zone = kargs.fetch :zone, zone end |
#to_greo ⇒ Object
20 21 22 |
# File 'lib/hijri/datetime.rb', line 20 def to_greo ::DateTime.new *Converter.hijri_to_greo(self) end |