class Time

Copyright © 2003-2006 Kouichirou Eto, All rights reserved. This is free software with ABSOLUTELY NO WARRANTY. You can redistribute it and/or modify it under the terms of the GNU GPL 2.

Public Class Methods

date_abbr(now, date) click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 47
def self.date_abbr(now, date)
  year  = date.year
  month = date.month
  mday  = date.mday
  return date.ymd if now.year != date.year
  return date.md
end
date_emphasis(now, date, title) click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 55
def self.date_emphasis(now, date, title)
  diff = date - now
  day = 60*60*24
  if diff < -day      # past
    return [:span, {:class=>'past'}, title]
  elsif diff < day*7  # This week.
    return [:strong, title]
  elsif diff < day*30 # This month.
    return [:em, title]
  else
    return [:span, {:class=>'future'}, title]
  end
end
date_parse(tag) click to toggle source
date
# File vendor/qwik/lib/qwik/util-time.rb, line 40
def self.date_parse(tag)
  if /\A(\d\d\d\d)-(\d\d)-(\d\d)\z/ =~ tag
    return Time.local($1.to_i, $2.to_i, $3.to_i)
  end
  return nil
end

Public Instance Methods

format_date() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 26
def format_date
  day = %w(日 月 火 水 木 金 土)     # 2000-01-01 (土) 12:34:56
  return strftime("%Y-%m-%d #DAY# %H:%M:%S").sub(/#DAY#/, "(#{day[wday]})")
end
md() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 6
def md
  return strftime('%m-%d')    # 01-01
end
rfc1123_date() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 31
def rfc1123_date
  return strftime('%a, %d %b %Y %H:%M:%S GMT') # Sat, 01 Jan 2000 12:34:56 GMT
end
rfc_date() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 35
def rfc_date
  return strftime('%Y-%m-%dT%H:%M:%S')        # 2000-01-01T12:34:56
end
ymd() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 14
def ymd
  return strftime('%Y-%m-%d') # 2000-01-01
end
ymd_s() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 10
def ymd_s
  return strftime('%Y%m%d')   # 20000101
end
ymdax() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 22
def ymdax
  return strftime("%Y-%m-%d(%a) %X")  # 2000-01-01(Sat) 12:34:56
end
ymdx() click to toggle source
# File vendor/qwik/lib/qwik/util-time.rb, line 18
def ymdx
  return strftime('%Y-%m-%d %X')      # 2000-01-01 12:34:56
end