Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/flv/core_extensions.rb

Constant Summary collapse

DAY_NAME =
[
  'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
]
MONTH_NAME =
[
  'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
]

Instance Method Summary collapse

Instance Method Details

#to_isoObject



50
51
52
53
# File 'lib/flv/core_extensions.rb', line 50

def to_iso
  offset = Time.now.gmtoff
  strftime("%Y-%m-%dT%H:%m:%S#{sprintf('%s%02d:%02d', (offset < 0 ? '-' : '+'), *(offset.abs / 60).divmod(60))}")
end

#to_sObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/flv/core_extensions.rb', line 36

def to_s
  sprintf('%s %s %d %02d:%02d:%02d GMT',
    DAY_NAME[wday],
    MONTH_NAME[mon-1], day,
    hour, min, sec) +
    (
      off = Time.now.gmtoff
      sign = off < 0 ? '-' : '+'
      sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
    ) +
    (
      sprintf(' %d', year)
    )
end

#to_strObject



28
# File 'lib/flv/core_extensions.rb', line 28

alias :to_str :to_s