module DockDriver::Template::DatesAndTimes

Adds date and time related methods to the DockDriver::Template DSL.

Public Instance Methods

beats( fmt = "@%0.0f") click to toggle source

Internet Time Examlpes:

<%= beats %>         => @203
<%= internet_time %> => @203
<%= beats "%0.1f" %> => 203.0
# File lib/dock_driver/template/dates_and_times.rb, line 51
def beats( fmt = "@%0.0f")
    return self.centibeats( fmt )
end
Also aliased as: internet_time
centibeats( fmt = "@%0.2f" ) click to toggle source

Internet Time with a fractional part. Examples:

<%= centibeats %>         => @203.44
<%= centibeats "%0.1f" %> => 203.4
# File lib/dock_driver/template/dates_and_times.rb, line 37
def centibeats( fmt = "@%0.2f" )
    # UTC+1 is the time base for Interet Time.
    now = Time.now.utc + 3600
    base = Time.gm( now.year, now.month, now.day, 1 )
    return fmt % [(now.to_f - base.to_f) * 0.01157407407]
end
date( fmt = "%F %T" ) click to toggle source

Returns a formatted date. Examples:

<%= date %>      => 2012-03-04 17:35:33
<%= time %>      => 2012-03-04 17:35:33
<%= date "%A" %> => Wednesday
# File lib/dock_driver/template/dates_and_times.rb, line 12
def date( fmt = "%F %T" )
    return Time.now.strftime( fmt )
end
Also aliased as: time
gmdate( fmt = "%F %T" ) click to toggle source

Returns a formatted date in GMT. Examples:

<%= gmdate %>      => 2012-03-04 17:35:33
<%= gmtime %>      => 2012-03-04 17:35:33
<%= gmdate "%A" %> => Tuesday
# File lib/dock_driver/template/dates_and_times.rb, line 25
def gmdate( fmt = "%F %T" )
    return Time.now.gmtime.strftime( fmt )
end
Also aliased as: gmtime
gmtime( fmt = "%F %T" )
Alias for: gmdate
internet_time( fmt = "@%0.0f")
Alias for: beats
time( fmt = "%F %T" )
Alias for: date