Skip to content

Commit a4971d9

Browse files
committed
Temporal#adjust_to_timezone! can certainly take a Literal::DayTimeOffset, in addition to a String.
Treat the empty string as nil, to remove the timezone.
1 parent 1caf735 commit a4971d9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/rdf/model/literal/temporal.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ def to_s
146146
#
147147
# Otherwise, the timezone is set based on the difference between the current timezone offset (if any) and `zone`.
148148
#
149-
# @param [String] zone (nil) In the form of {ZONE_GRAMMAR}.
149+
# @param [DayTimeDuration, String] zone (nil) In the form of {ZONE_GRAMMAR}.
150150
# @return [Temporal] `self`
151151
# @raise [RangeError] if `zone < -14*60` or `zone > 14*60`
152152
# @see https://www.w3.org/TR/xpath-functions/#func-adjust-dateTime-to-timezone
153153
def adjust_to_timezone!(*args)
154154
zone = args.empty? ? '+00:00' : args.first
155-
if zone.nil?
155+
if zone.to_s.empty?
156156
# Remove timezone component
157157
@object = self.class.new(@object.strftime(self.class.const_get(:FORMAT))).object
158158
@zone = nil
159159
else
160-
md = zone.match(ZONE_GRAMMAR)
160+
md = zone.to_s.match(ZONE_GRAMMAR)
161161
raise ArgumentError,
162162
"expected #{zone.inspect} to be a xsd:dayTimeDuration or +/-HH:MM" unless md
163163

0 commit comments

Comments
 (0)