-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strftime_spec.rb SPEC test fails in "returns the timezone with %Z" #3303
Milestone
Comments
Fixed in 1.7.22 and 9.0.1.0. |
tdaitx
added a commit
to tdaitx/jruby
that referenced
this issue
Sep 4, 2015
According to the spec "%Z" and RubyTime#zone should behave the same. This fix reuses RubyTime#zone to avoid code duplication.
tdaitx
added a commit
to tdaitx/jruby
that referenced
this issue
Sep 15, 2015
According to the spec "%Z" and Time#zone should behave the same. This fix makes use of RubyTime.getRubyTimeZoneName to closely mimic RubyTime.zone behavior. Note that it is still possible to fail the above spec when the RubyTime object is created with a numeric TZ relative to UTC (thus setting isTzRelative to true) because there is no way to reproduce this particular behavior from within RubyDateFormatter.
tdaitx
added a commit
to tdaitx/jruby
that referenced
this issue
Sep 15, 2015
According to the spec "%Z" and Time#zone should behave the same. This fix makes use of RubyTime.getRubyTimeZoneName to closely mimic RubyTime.zone behavior. Note that it is still possible to fail the above spec when the RubyTime object is created with a numeric TZ relative to UTC (thus setting isTzRelative to true) because there is no way to reproduce this particular behavior from within RubyDateFormatter.
tdaitx
added a commit
to tdaitx/jruby
that referenced
this issue
Sep 16, 2015
According to the spec "%Z" and Time#zone should behave the same. This fix makes use of RubyTime.getRubyTimeZoneName to closely mimic RubyTime.zone behavior. Note that it is still possible to fail the above spec when the RubyTime object is created with a numeric TZ relative to UTC (thus setting isTzRelative to true) because there is no way to reproduce this particular behavior from within RubyDateFormatter.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In certain cases
Time#zone
andTime#strftime("%Z")
might not match, causing "returns the timezone with %Z" inspec/ruby/core/time/strftime_spec.rb
to fail.How to reproduce
One of such cases happens when running joda-time <= 2.8.0 and OpenJDK 8u60 or earlier.
Due to a change in OpenJDK 8u60, Java's
DateTimeUtils.getZoneStrings()
is now returning 7 elements instead of just 5, causing joda-timeDefaultNameFormatter.getName()
to returnnull
. In effect causing joda-timeDateTimeZone.getShortName()
orDateTimeZone.getName()
to return TZ in [+-]hh:mm format instead of the abbreviation name. The issue was reported in JodaOrg/joda-time#288 and JodaOrg/joda-time#291.To reproduce simply run:
with joda-time <= 2.8.0.
Current result:
Requires OpenJDK 8u60 (or earlier) and joda-time <= 2.8.0.
Time.strftime("%Z")
returns the TZ in_"[+-]hh:mm_ format (as if "%z" was given), whileTime.zone
returns the TZ abbreviation name.Expected result:
The spec states that
Time#zone
andTime#strftime("%Z")
should always match. Also, Time.strftime documentation states that %Z - Time zone abbreviation name.Background, why Time#zone and Time#strftime differs
JRuby's
Time#zone
has additional code to be able to handle a [+-]hh:mm return byDateTimeZone.getShortName()
when compared toTime#strftime("%Z")
.RubyTime.zone() [890-908]
RubyDateFormatter.format() [489-491] and
RubyDateFormat.format() [622-624]
Some code from
RubyTime.zone()
offsetMatcher should be refactored (or copied) intoRubyDateFormatter.format()
andRubyDateFormat.format()
FORMAT_ZONE_ID clauses.The text was updated successfully, but these errors were encountered: