summaryrefslogtreecommitdiff
path: root/lib/date/format.rb
diff options
context:
space:
mode:
authortadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-20 16:52:59 +0000
committertadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-20 16:52:59 +0000
commit6683940715a917e79050e01e0f02c9642c8ffa00 (patch)
tree31c361727aceb0614a0883c2645226bbfaeb3162 /lib/date/format.rb
parent644d3a650fc31c865bb87d53de6624f876bf68dd (diff)
* lib/date/format.rb (Date._parse): completes calendar week based year.
* lib/date/format.rb (Date._parse): detects year of ordinal date in extended format. * and some trivial adjustments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/date/format.rb')
-rw-r--r--lib/date/format.rb40
1 files changed, 23 insertions, 17 deletions
diff --git a/lib/date/format.rb b/lib/date/format.rb
index e2339827c5..b943822597 100644
--- a/lib/date/format.rb
+++ b/lib/date/format.rb
@@ -1,5 +1,5 @@
# format.rb: Written by Tadayoshi Funaba 1999-2007
-# $Id: format.rb,v 2.35 2007-05-19 09:23:48+09 tadf Exp $
+# $Id: format.rb,v 2.36 2007-07-21 00:21:04+09 tadf Exp $
require 'rational'
@@ -652,7 +652,7 @@ class Date
private_class_method :s3e
def self._parse_day(str, e) # :nodoc:
- if str.sub!(/\b(#{Format::ABBR_DAYS.keys.join('|')})[^-\d\s]*/ino, ' ')
+ if str.sub!(/\b(#{Format::ABBR_DAYS.keys.join('|')})[^-\d\s]*/in, ' ')
e.wday = Format::ABBR_DAYS[$1.downcase]
true
=begin
@@ -748,7 +748,7 @@ class Date
\s*
('?-?\d+(?:(?:st|nd|rd|th)\b)?)
)?
- /inox,
+ /inx,
' ') # '
s3e(e, $4, Format::ABBR_MONTHS[$2.downcase], $1,
$3 && $3[0,1].downcase == 'b')
@@ -767,7 +767,7 @@ class Date
\s*
('?-?\d+)
)?
- /inox,
+ /inx,
' ') # '
s3e(e, $4, Format::ABBR_MONTHS[$1.downcase], $2,
$3 && $3[0,1].downcase == 'b')
@@ -789,7 +789,7 @@ class Date
e.cwday = $3.to_i if $3
true
elsif str.sub!(/-w-(\d)\b/in, ' ')
- e.cwday = $1.to_i
+ e.cwday = $1.to_i
true
elsif str.sub!(/--(\d{2})?-(\d{2})\b/n, ' ')
e.mon = $1.to_i if $1
@@ -799,14 +799,15 @@ class Date
e.mon = $1.to_i
e.mday = $2.to_i if $2
true
- elsif str.sub!(/-(\d{3})\b/n, ' ')
- e.yday = $1.to_i
+ elsif str.sub!(/\b(\d{2}|\d{4})?-(\d{3})\b/n, ' ')
+ e.year = $1.to_i if $1
+ e.yday = $2.to_i
true
end
end
def self._parse_jis(str, e) # :nodoc:
- if str.sub!(/\b([MTSH])(\d+)\.(\d+)\.(\d+)/in, ' ')
+ if str.sub!(/\b([mtsh])(\d+)\.(\d+)\.(\d+)/in, ' ')
era = { 'm'=>1867,
't'=>1911,
's'=>1925,
@@ -821,11 +822,11 @@ class Date
def self._parse_vms(str, e) # :nodoc:
if str.sub!(/('?-?\d+)-(#{Format::ABBR_MONTHS.keys.join('|')})[^-]*
- -('?-?\d+)/inox, ' ')
+ -('?-?\d+)/inx, ' ')
s3e(e, $3, Format::ABBR_MONTHS[$2.downcase], $1)
true
elsif str.sub!(/\b(#{Format::ABBR_MONTHS.keys.join('|')})[^-]*
- -('?-?\d+)(?:-('?-?\d+))?/inox, ' ')
+ -('?-?\d+)(?:-('?-?\d+))?/inx, ' ')
s3e(e, $3, Format::ABBR_MONTHS[$1.downcase], $2)
true
end
@@ -853,7 +854,7 @@ class Date
end
def self._parse_mon(str, e) # :nodoc:
- if str.sub!(/\b(#{Format::ABBR_MONTHS.keys.join('|')})\S*/ino, ' ')
+ if str.sub!(/\b(#{Format::ABBR_MONTHS.keys.join('|')})\S*/in, ' ')
e.mon = Format::ABBR_MONTHS[$1.downcase]
true
end
@@ -1050,12 +1051,17 @@ class Date
end
end
- if e._comp && e.year
- if e.year >= 0 && e.year <= 99
- if e.year >= 69
- e.year += 1900
- else
- e.year += 2000
+ if e._comp
+ if e.cwyear
+ if e.cwyear >= 0 && e.cwyear <= 99
+ e.cwyear += if e.cwyear >= 69
+ then 1900 else 2000 end
+ end
+ end
+ if e.year
+ if e.year >= 0 && e.year <= 99
+ e.year += if e.year >= 69
+ then 1900 else 2000 end
end
end
end