Class: DateTime

Inherits:
Object show all
Includes:
TimeFunctions
Defined in:
lib/sequel/fos_dates.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TimeFunctions

#as_minutes, #hm, #in_hundredths, #in_hundredths_rounded_xos, #in_tenths_rounded_xos, #to_fos_days

Class Method Details

.from_fos_date_time(days, minutes) ⇒ Object

creates utc time from days and minutes



117
118
119
120
121
# File 'lib/sequel/fos_dates.rb', line 117

def self.from_fos_date_time(days, minutes)
  days = 0 unless days
  minutes = 0 unless minutes
  (Date.from_fos_days(days).to_gm_time + minutes.minutes).to_datetime
end

.from_fos_time(minutes) ⇒ Object Also known as: from_minutes

using a date of 2000,1,1 is arbitrary



111
112
113
114
# File 'lib/sequel/fos_dates.rb', line 111

def self.from_fos_time(minutes)
  minutes = 0 unless minutes
  (Time.utc(2000, 1, 1) + minutes.minutes).to_datetime
end

Instance Method Details

#long_viewObject

This is a view “February 01, 2010 01:40” that be parsed directly by javascript ie. in javascript you can say: Date.parse( “this to long view” ) and you will get a date object



134
135
136
# File 'lib/sequel/fos_dates.rb', line 134

def long_view
  self.strftime('%B %d, %Y %H:%M')
end

#to_dateObject

Converts self to a Ruby Date object; time portion is discarded



139
140
141
# File 'lib/sequel/fos_dates.rb', line 139

def to_date
  ::Date.new(year, month, day)
end

#viewObject



127
128
129
# File 'lib/sequel/fos_dates.rb', line 127

def view
  to_s
end