Class: Time
Class Method Summary collapse
-
.from_fos_time(minutes) ⇒ Object
(also: from_minutes)
using a date of 2000,1,1 is arbitrary.
Instance Method Summary collapse
-
#long_view ⇒ Object
This is a view “February 01, 2010 01:40” that be parsed directly by javascript ie.
- #original_to_s ⇒ Object
-
#to_datetime ⇒ Object
from Ruby Cookbook #########.
- #to_s(args = nil) ⇒ Object
Methods included from TimeFunctions
#as_minutes, #hm, #in_hundredths, #in_hundredths_rounded_xos, #in_tenths_rounded_xos, #to_fos_days
Class Method Details
Instance Method Details
#long_view ⇒ Object
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
102 103 104 |
# File 'lib/sequel/fos_dates.rb', line 102 def long_view self.strftime('%B %d, %Y %H:%M') end |
#original_to_s ⇒ Object
71 |
# File 'lib/sequel/fos_dates.rb', line 71 alias :original_to_s :to_s |
#to_datetime ⇒ Object
from Ruby Cookbook #########
89 90 91 92 93 94 95 96 97 |
# File 'lib/sequel/fos_dates.rb', line 89 def to_datetime # Convert seconds + microseconds into a fractional number of seconds seconds = sec + Rational(usec, 10**6) # Convert a UTC offset measured in minutes to one measured in a # fraction of a day. offset = Rational(utc_offset, 60 * 60 * 24) DateTime.new(year, month, day, hour, min, seconds, offset) end |
#to_s(args = nil) ⇒ Object
73 74 75 76 |
# File 'lib/sequel/fos_dates.rb', line 73 def to_s(args=nil) return self.strftime('%H:%M') if args == :hm or !args self.original_to_s(args) end |