958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
|
# File 'lib/date/format.rb', line 958
def self._parse(str, comp=false)
str = str.dup
e = Format::Bag.new
e._comp = comp
str.gsub!(/[^-+',.\/:0-9@a-z\x80-\xff]+/in, ' ')
_parse_time(str, e) _parse_day(str, e)
_parse_eu(str, e) ||
_parse_us(str, e) ||
_parse_iso(str, e) ||
_parse_jis(str, e) ||
_parse_vms(str, e) ||
_parse_sla_us(str, e) ||
_parse_iso2(str, e) ||
_parse_year(str, e) ||
_parse_mon(str, e) ||
_parse_mday(str, e) ||
_parse_ddd(str, e)
if str.sub!(/\b(bc\b|bce\b|b\.c\.|b\.c\.e\.)/in, ' ')
if e.year
e.year = -e.year + 1
end
end
if str.sub!(/\A\s*(\d{1,2})\s*\z/n, ' ')
if e.hour && !e.mday
v = $1.to_i
if (1..31) === v
e.mday = v
end
end
if e.mday && !e.hour
v = $1.to_i
if (0..24) === v
e.hour = v
end
end
end
if e._comp and e.year
if e.year >= 0 and e.year <= 99
if e.year >= 69
e.year += 1900
else
e.year += 2000
end
end
end
e.offset ||= zone_to_diff(e.zone) if e.zone
e.to_hash
end
|