Class: DateTime

Inherits:
Object show all
Defined in:
lib/doh/core/date.rb,
lib/doh/mysql/to_sql.rb,
lib/doh/util/to_display.rb

Direct Known Subclasses

DohDb::DateTimeNow

Constant Summary collapse

DOHRUBY_SECONDS_IN_DAY =
(24 * 60 * 60).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.zowObject



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_onlyObject



85
86
87
# File 'lib/doh/core/date.rb', line 85

def date_only
  Date.new(year, month, mday)
end

#inspectObject



81
82
83
# File 'lib/doh/core/date.rb', line 81

def inspect
  strftime('%F %X')
end

#make_datetimeObject



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_displayObject



11
12
13
# File 'lib/doh/util/to_display.rb', line 11

def to_display
  strftime('%m/%d/%Y %I:%M%P')
end

#to_sqlObject



38
39
40
# File 'lib/doh/mysql/to_sql.rb', line 38

def to_sql
  '"' + strftime('%Y-%m-%d %H:%M:%S') + '"'
end