Skip to content

Commit 78a0517

Browse files
authored
Merge pull request #576 from ruby/bump-3-3-3
Bump up v3.3.3
2 parents 54dbf51 + ff200f1 commit 78a0517

6 files changed

Lines changed: 34 additions & 14 deletions

File tree

.github/workflows/ubuntu-jruby.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ jobs:
1616
with:
1717
ruby-version: ${{ matrix.ruby }}
1818
- name: Install dependencies
19-
run: |
20-
gem install bundler --no-document
21-
bundle install
19+
run: gem install ruby-maven power_assert test-unit rake-compiler
2220
- name: compile
2321
run: rake compile
2422
- name: test

lib/psych/scalar_scanner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def tokenize string
5757
elsif string.match?(/^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/)
5858
require 'date'
5959
begin
60-
class_loader.date.strptime(string, '%Y-%m-%d')
60+
class_loader.date.strptime(string, '%F', Date::GREGORIAN)
6161
rescue ArgumentError
6262
string
6363
end

lib/psych/versions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Psych
44
# The version of Psych you are using
5-
VERSION = '3.3.2'
5+
VERSION = '3.3.3'
66

77
if RUBY_ENGINE == 'jruby'
88
DEFAULT_SNAKEYAML_VERSION = '1.31'.freeze

lib/psych/visitors/to_ruby.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def deserialize o
8080
when "!ruby/object:DateTime"
8181
class_loader.date_time
8282
require 'date' unless defined? DateTime
83-
@ss.parse_time(o.value).to_datetime
83+
t = @ss.parse_time(o.value)
84+
DateTime.civil(*t.to_a[0, 6].reverse, Rational(t.utc_offset, 86400)) +
85+
(t.subsec/86400)
8486
when '!ruby/encoding'
8587
::Encoding.find o.value
8688
when "!ruby/object:Complex"

lib/psych/visitors/yaml_tree.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ def visit_Regexp o
192192
register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
193193
end
194194

195+
def visit_Date o
196+
register o, visit_Integer(o.gregorian)
197+
end
198+
195199
def visit_DateTime o
196-
formatted = if o.offset.zero?
197-
o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
198-
else
199-
o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
200-
end
200+
t = o.italy
201+
formatted = format_time t, t.offset.zero?
201202
tag = '!ruby/object:DateTime'
202203
register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
203204
end
@@ -235,7 +236,6 @@ def visit_Integer o
235236
end
236237
alias :visit_TrueClass :visit_Integer
237238
alias :visit_FalseClass :visit_Integer
238-
alias :visit_Date :visit_Integer
239239

240240
def visit_Float o
241241
if o.nan?
@@ -480,8 +480,8 @@ def dump_exception o, msg
480480
@emitter.end_mapping
481481
end
482482

483-
def format_time time
484-
if time.utc?
483+
def format_time time, utc = time.utc?
484+
if utc
485485
time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
486486
else
487487
time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")

test/psych/test_date_time.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ def test_datetime_timezone_offset
4444
assert_match(/12:00:00-05:00/, cycled.last.to_s)
4545
end
4646

47+
def test_julian_date
48+
d = Date.new(1582, 10, 4, Date::GREGORIAN)
49+
assert_cycle d
50+
end
51+
52+
def test_proleptic_gregorian_date
53+
d = Date.new(1582, 10, 14, Date::GREGORIAN)
54+
assert_cycle d
55+
end
56+
57+
def test_julian_datetime
58+
dt = DateTime.new(1582, 10, 4, 23, 58, 59, 0, Date::GREGORIAN)
59+
assert_cycle dt
60+
end
61+
62+
def test_proleptic_gregorian_datetime
63+
dt = DateTime.new(1582, 10, 14, 23, 58, 59, 0, Date::GREGORIAN)
64+
assert_cycle dt
65+
end
66+
4767
def test_invalid_date
4868
assert_cycle "2013-10-31T10:40:07-000000000000033"
4969
end

0 commit comments

Comments
 (0)