Class: DateTime
- Defined in:
- lib/doh/core/date.rb,
lib/doh/mysql/to_sql.rb,
lib/doh/util/to_display.rb
Direct Known Subclasses
Constant Summary collapse
- DOHRUBY_SECONDS_IN_DAY =
(24 * 60 * 60).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #add_seconds(seconds) ⇒ Object
- #date_only ⇒ Object
- #inspect ⇒ Object
- #make_datetime ⇒ Object
-
#sub_dt(other) ⇒ Object
subtract another DateTime object, return difference in seconds.
- #sub_seconds(seconds) ⇒ Object
- #to_display ⇒ Object
- #to_sql ⇒ Object
Class Method Details
.zow ⇒ Object
76 77 78 79 |
# File 'lib/doh/core/date.rb', line 76 def self.zow obj = now new(obj.year, obj.month, obj.mday, obj.hour, obj.min, obj.sec) end |
Instance Method Details
#add_seconds(seconds) ⇒ Object
89 90 91 |
# File 'lib/doh/core/date.rb', line 89 def add_seconds(seconds) self + Rational(seconds, DOHRUBY_SECONDS_IN_DAY) end |
#date_only ⇒ Object
85 86 87 |
# File 'lib/doh/core/date.rb', line 85 def date_only Date.new(year, month, mday) end |
#inspect ⇒ Object
81 82 83 |
# File 'lib/doh/core/date.rb', line 81 def inspect strftime('%F %X') end |
#make_datetime ⇒ Object
102 103 104 |
# File 'lib/doh/core/date.rb', line 102 def make_datetime self end |
#sub_dt(other) ⇒ Object
subtract another DateTime object, return difference in seconds
98 99 100 |
# File 'lib/doh/core/date.rb', line 98 def sub_dt(other) ((self - other) * DOHRUBY_SECONDS_IN_DAY).to_i end |
#sub_seconds(seconds) ⇒ Object
93 94 95 |
# File 'lib/doh/core/date.rb', line 93 def sub_seconds(seconds) add_seconds(-seconds) end |
#to_display ⇒ Object
11 12 13 |
# File 'lib/doh/util/to_display.rb', line 11 def to_display strftime('%m/%d/%Y %I:%M%P') end |
#to_sql ⇒ Object
38 39 40 |
# File 'lib/doh/mysql/to_sql.rb', line 38 def to_sql '"' + strftime('%Y-%m-%d %H:%M:%S') + '"' end |