summaryrefslogtreecommitdiff
path: root/lib/time.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-24 11:34:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-24 11:34:45 +0000
commit54370de9f4c01ba43752057b602bafc5be293665 (patch)
treea1843c45a65e1050416769821b4fa8eb3c5cc07e /lib/time.rb
parentdb1564ec1d48dd2e898c7ca11eed523e92c78f46 (diff)
* strftime.c: %Y format a year with 4 digits at least.
* lib/time.rb: format a year with 4 digits at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/time.rb')
-rw-r--r--lib/time.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/time.rb b/lib/time.rb
index 2e6ed324e3..f2ba18e51c 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -432,9 +432,9 @@ class Time
# If +self+ is a UTC time, -0000 is used as zone.
#
def rfc2822
- sprintf('%s, %02d %s %04d %02d:%02d:%02d ',
+ sprintf('%s, %02d %s %0*d %02d:%02d:%02d ',
RFC2822_DAY_NAME[wday],
- day, RFC2822_MONTH_NAME[mon-1], year,
+ day, RFC2822_MONTH_NAME[mon-1], year < 0 ? 5 : 4, year,
hour, min, sec) +
if utc?
'-0000'
@@ -464,9 +464,9 @@ class Time
#
def httpdate
t = dup.utc
- sprintf('%s, %02d %s %04d %02d:%02d:%02d GMT',
+ sprintf('%s, %02d %s %0*d %02d:%02d:%02d GMT',
RFC2822_DAY_NAME[t.wday],
- t.day, RFC2822_MONTH_NAME[t.mon-1], t.year,
+ t.day, RFC2822_MONTH_NAME[t.mon-1], t.year < 0 ? 5 : 4, t.year,
t.hour, t.min, t.sec)
end
@@ -485,8 +485,8 @@ class Time
# Its default value is 0.
#
def xmlschema(fraction_digits=0)
- sprintf('%04d-%02d-%02dT%02d:%02d:%02d',
- year, mon, day, hour, min, sec) +
+ sprintf('%0*d-%02d-%02dT%02d:%02d:%02d',
+ year < 0 ? 5 : 4, year, mon, day, hour, min, sec) +
if fraction_digits == 0
''
else