class EZTime::FormattedTime

Attributes

time[RW]

Public Class Methods

new(time) click to toggle source
# File lib/eztime.rb, line 31
def initialize(time)
  @time = time
end

Public Instance Methods

aday()
Alias for: day_abbr
amonth()
Alias for: month_abbr
day_abbr() click to toggle source

Returns the abbreviated name of the weekday (Sun, Mon, etc.)

# File lib/eztime.rb, line 58
def day_abbr; Date::ABBR_DAYNAMES[wday]; end
Also aliased as: aday
day_name() click to toggle source

Returns the name of the weekday (Sunday, Monday, etc.)

# File lib/eztime.rb, line 54
def day_name; Date::DAYNAMES[wday]; end
Also aliased as: nday
format(format_str) click to toggle source
# File lib/eztime.rb, line 35
def format(format_str)
  eval("'" + format_str.gsub(/:([a-z_]{1,}[0-9]{0,2})/, '\' + \1.to_s + \'') + "'")
end
hour12() click to toggle source

Returns the hour in 12-hour format (5:00pm => 5)

# File lib/eztime.rb, line 80
def hour12;  hour % 12 == 0 ? 12 : hour % 12; end
lmeridian() click to toggle source

Returns the meridian in lowercase (am/pm)

# File lib/eztime.rb, line 104
def lmeridian;  meridian.downcase; end
lsmeridian() click to toggle source

Returns the meridian in lowercase, short form (first letter) (a/p)

# File lib/eztime.rb, line 108
def lsmeridian; smeridian.downcase; end
meridian() click to toggle source

Returns the meridian (AM/PM)

# File lib/eztime.rb, line 96
def meridian;   hour >= 12 ? 'PM' : 'AM'; end
minute() click to toggle source

Returns the minute as a zero-padded string Note: If you need just the minute, use min

# File lib/eztime.rb, line 88
def minute;  '%02d' % min; end
month_abbr() click to toggle source

Returns the abbreviated name of the month (Jan, Feb, etc.)

# File lib/eztime.rb, line 50
def month_abbr; Date::ABBR_MONTHNAMES[month]; end
Also aliased as: amonth
month_name() click to toggle source

Returns the name of the month (January, February, etc.)

# File lib/eztime.rb, line 46
def month_name; Date::MONTHNAMES[month]; end
Also aliased as: nmonth
nday()
Alias for: day_name
nmonth()
Alias for: month_name
ord()
Alias for: ordinal
ordinal() click to toggle source

Returns the ordinal of the day (1 => st, 2 => nd, 3 => rd, 4.. => th)

# File lib/eztime.rb, line 112
def ordinal; EZTime.ordinal(mday, false); end
Also aliased as: ord
second() click to toggle source

Returns the second as a zero-padded string Note: If you need just the second, use sec

# File lib/eztime.rb, line 92
def second;  '%02d' % sec; end
smeridian() click to toggle source

Returns the meridian in short form (first letter) (A/P)

# File lib/eztime.rb, line 100
def smeridian;  meridian[0].chr; end
syear() click to toggle source

Returns only the lower two digits of the year (i.e. 2006 => 06)

# File lib/eztime.rb, line 42
def syear; year.to_s[-2..-1]; end
zday() click to toggle source

Returns the day as a zero-padded string (5 => 05)

# File lib/eztime.rb, line 72
def zday;   '%02d' % mday;  end
zhour() click to toggle source

Returns the hour as a zero-padded string (3 => 03)

# File lib/eztime.rb, line 76
def zhour;  '%02d' % hour; end
zhour12() click to toggle source

Returns the hour in 12-hour format as a zero-padded string (5:00pm => 05)

# File lib/eztime.rb, line 84
def zhour12; '%02d' % hour12; end
zmonth() click to toggle source

Returns the month as a zero-padded string (i.e. June => 06)

# File lib/eztime.rb, line 68
def zmonth; '%02d' % month; end