You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Converts this literal into its canonical lexical representation.
46
-
#
47
-
# Note that the timezone is recoverable for xsd:date, where it is not for xsd:dateTime and xsd:time, which are both transformed relative to Z, if a timezone is provided.
48
-
#
49
-
# @return [RDF::Literal] `self`
50
-
# @see http://www.w3.org/TR/xmlschema11-2/#date
51
-
defcanonicalize!
52
-
ifself.valid? && @zone && @zone != '+00:00'
53
-
adjust_to_timezone!
54
-
else
55
-
@string=nil
56
-
end
57
-
self
58
-
end
59
-
60
-
##
61
-
# Returns `true` if the value adheres to the defined grammar of the
62
-
# datatype.
63
-
#
64
-
# Special case for date and dateTime, for which '0000' is not a valid year
65
-
#
66
-
# @return [Boolean]
67
-
# @since 0.2.1
68
-
defvalid?
69
-
super && object && value !~ %r(\A0000)
70
-
end
71
-
72
-
##
73
-
# Returns the value as a string.
74
-
#
75
-
# @return [String]
76
-
defto_s
77
-
@string || (@object.strftime(FORMAT) + self.tz)
78
-
end
79
-
80
44
##
81
45
# Returns a human-readable value for the literal
82
46
#
@@ -93,165 +57,5 @@ def humanize(lang = :en)
93
57
end
94
58
d
95
59
end
96
-
97
-
##
98
-
# Does the literal representation include a timezone? Note that this is only possible if initialized using a string, or `:lexical` option.
99
-
#
100
-
# @return [Boolean]
101
-
# @since 1.1.6
102
-
deftimezone?
103
-
!@zone.nil?
104
-
end
105
-
alias_method:tz?,:timezone?
106
-
alias_method:has_tz?,:timezone?
107
-
alias_method:has_timezone?,:timezone?
108
-
109
-
##
110
-
# Adjust the timezone.
111
-
#
112
-
# From [fn:adjust-date-to-timezone](https://www.w3.org/TR/xpath-functions/#func-adjust-date-to-timezone)
113
-
#
114
-
# @overload adjust_to_timezone!
115
-
# Adjusts the timezone to UTC.
116
-
#
117
-
# @return [Date] `self`
118
-
# @raise [RangeError] if `zone < -14*60` or `zone > 14*60`
119
-
# @overload adjust_to_timezone!(zone)
120
-
# If `zone` is nil, then the timzeone component is removed.
121
-
#
122
-
# Otherwise, the timezone is set based on the difference between the current timezone offset (if any) and `zone`.
123
-
#
124
-
# @param [String] zone (nil) In the form of {ZONE_FORMAT}
125
-
# @return [Date] `self`
126
-
# @raise [RangeError] if `zone < -14*60` or `zone > 14*60`
0 commit comments