class ICalPal::RDT
Child class of DateTime that adds support for relative dates (RelativeDateTime).
def self.conv(str)
-
(RDT)
- a new RDT
Parameters:
-
str
(String
) -- can be +yesterday+, +today+, +tomorrow+,
def self.conv(str) case str when 'yesterday' then $today - 1 when 'today' then $today when 'tomorrow' then $today + 1 when /^\+([0-9]+)/ then $today + Regexp.last_match(1).to_i when /^-([0-9]+)/ then $today - Regexp.last_match(1).to_i else parse(str) end end
def self.from_epoch(s)
def self.from_epoch(s) from_time(Time.at(s)) end
def self.from_itime(s)
def self.from_itime(s) from_epoch(s + ITIME) end
def self.from_time(t)
def self.from_time(t) new(*t.to_a[0..5].reverse) end
def ==(other)
-
(Boolean)
-
Other tags:
- See: ICalPal::RDT.to_s -
def ==(other) self.to_s == other.to_s end
def to_a
-
(Array)
- Self as an array
Other tags:
- See: Time.to_a -
def to_a [ year, month, day, hour, min, sec ] end
def to_i
-
(Integer)
- Seconds since epoch
def to_i to_time.to_i end
def to_s
-
(String)
- A string representation of self relative to
def to_s return strftime($opts[:df]) if $opts && $opts[:nrd] && $opts[:df] case Integer(RDT.new(year, month, day) - $today) when -2 then 'day before yesterday' when -1 then 'yesterday' when 0 then 'today' when 1 then 'tomorrow' when 2 then 'day after tomorrow' else strftime($opts[:df]) if $opts && $opts[:df] end end
def ymd
-
(Array)
- Only the year, month and day of self
def ymd [ year, month, day ] end