Skip to content

Commit e0a7f99

Browse files
committed
Generalize string handling
1 parent 4ad288d commit e0a7f99

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/class.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838

3939
function Class(str::AbstractString, regions::AbstractSet{<:AbstractString})
4040
class = Class(:NONE)
41-
occursin(FIXED_TIME_ZONE_REGEX, String(str)) && (class |= Class(:FIXED))
41+
occursin(FIXED_TIME_ZONE_REGEX, str) && (class |= Class(:FIXED))
4242
!isempty(intersect(regions, TZData.STANDARD_REGIONS)) && (class |= Class(:STANDARD))
4343
!isempty(intersect(regions, TZData.LEGACY_REGIONS)) && (class |= Class(:LEGACY))
4444
return class

src/types/timezone.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,16 @@ US/Pacific (UTC-8/UTC-7)
6464
"""
6565
TimeZone(::AbstractString, ::Class)
6666

67-
TimeZone(str::AbstractString, args...) = TimeZone(String(str), args...)
68-
69-
function TimeZone(str::String, mask::Class=Class(:DEFAULT))
67+
function TimeZone(str::AbstractString, mask::Class=Class(:DEFAULT))
7068
# Note: If the class `mask` does not match the time zone we'll still load the
7169
# information into the cache to ensure the result is consistent.
72-
tz, class = get!(_tz_cache(), String(str)) do
73-
tz_path = joinpath(TZData.COMPILED_DIR, split(String(str), "/")...)
70+
tz, class = get!(_tz_cache(), str) do
71+
tz_path = joinpath(TZData.COMPILED_DIR, split(str, "/")...)
7472

7573
if isfile(tz_path)
7674
open(deserialize, tz_path, "r")
77-
elseif occursin(FIXED_TIME_ZONE_REGEX, String(str))
78-
FixedTimeZone(String(str)), Class(:FIXED)
75+
elseif occursin(FIXED_TIME_ZONE_REGEX, str)
76+
FixedTimeZone(str), Class(:FIXED)
7977
elseif !isdir(TZData.COMPILED_DIR) || isempty(readdir(TZData.COMPILED_DIR))
8078
# Note: Julia 1.0 supresses the build logs which can hide issues in time zone
8179
# compliation which result in no tzdata time zones being available.
@@ -119,7 +117,7 @@ Check whether a string is a valid for constructing a `TimeZone` with the provide
119117
"""
120118
function istimezone(str::AbstractString, mask::Class=Class(:DEFAULT))
121119
# Start by performing quick FIXED class test
122-
if mask & Class(:FIXED) != Class(:NONE) && occursin(FIXED_TIME_ZONE_REGEX, String(str))
120+
if mask & Class(:FIXED) != Class(:NONE) && occursin(FIXED_TIME_ZONE_REGEX, str)
123121
return true
124122
end
125123

0 commit comments

Comments
 (0)