Skip to content

Commit 01ad66b

Browse files
simonmcconnellbitwalker
authored andcommitted
use ~c"" for charlists
1 parent c45b9a7 commit 01ad66b

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1111
- Fixed compilation warning from gettext
1212
- Added `cycled` option for `Timex.between?/4` to support time-range checks that pass through midnight
1313
- Add Croatian translation
14+
- Changed charlists from the deprecated `''` to `~c""`
1415

1516
### Fixed
1617

lib/parse/duration/parsers/iso8601.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Timex.Parse.Duration.Parsers.ISO8601Parser do
44
"""
55
use Timex.Parse.Duration.Parser
66

7-
@numeric '.0123456789'
7+
@numeric ~c".0123456789"
88

99
@doc """
1010
Parses an ISO-8601 formatted duration string into a Duration struct.
@@ -127,7 +127,7 @@ defmodule Timex.Parse.Duration.Parsers.ISO8601Parser do
127127
defp parse_component(<<c::utf8>>, _acc) when c in @numeric,
128128
do: {:error, "unexpected end of input at #{<<c::utf8>>}"}
129129

130-
defp parse_component(<<c::utf8>>, {type, acc}) when c in 'WYMDHS' do
130+
defp parse_component(<<c::utf8>>, {type, acc}) when c in ~c"WYMDHS" do
131131
case cast_number(type, acc) do
132132
{n, _} -> {c, n, <<>>}
133133
:error -> {:error, "invalid number `#{acc}`"}
@@ -146,7 +146,7 @@ defmodule Timex.Parse.Duration.Parsers.ISO8601Parser do
146146
parse_component(rest, {:float, <<acc::binary, c::utf8>>})
147147
end
148148

149-
defp parse_component(<<c::utf8, rest::binary>>, {type, acc}) when c in 'WYMDHS' do
149+
defp parse_component(<<c::utf8, rest::binary>>, {type, acc}) when c in ~c"WYMDHS" do
150150
case cast_number(type, acc) do
151151
{n, _} -> {c, n, rest}
152152
:error -> {:error, "invalid number `#{acc}`"}

lib/timezone/local.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,16 @@ defmodule Timex.Timezone.Local do
150150
end
151151

152152
# Get the locally configured timezone on Windows systems
153-
@local_tz_key 'SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation'
154-
@sys_tz_key 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones'
155-
@tz_key_name 'TimeZoneKeyName'
153+
@local_tz_key ~c"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation"
154+
@sys_tz_key ~c"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
155+
@tz_key_name ~c"TimeZoneKeyName"
156156
# We ignore the reference date here, since there is no way to lookup
157157
# transition times for historical/future dates
158158
defp localtz(:win) do
159159
# Windows has many of its own unique time zone names, which can
160160
# also be translated to the OS's language.
161161
{:ok, handle} = :win32reg.open([:read])
162-
:ok = :win32reg.change_key(handle, '\\local_machine\\#{@local_tz_key}')
162+
:ok = :win32reg.change_key(handle, ~c"\\local_machine\\#{@local_tz_key}")
163163
{:ok, values} = :win32reg.values(handle)
164164

165165
if List.keymember?(values, @tz_key_name, 0) do
@@ -177,7 +177,7 @@ defmodule Timex.Timezone.Local do
177177
else
178178
# Windows 2000 or XP
179179
# This is the localized name:
180-
localized = List.keyfind(values, 'StandardName', 0)
180+
localized = List.keyfind(values, ~c"StandardName", 0)
181181
# Open the list of timezones to look up the real name:
182182
:ok = :win32reg.change_key(handle, @sys_tz_key)
183183
{:ok, subkeys} = :win32reg.sub_keys(handle)
@@ -187,7 +187,7 @@ defmodule Timex.Timezone.Local do
187187
:ok = :win32reg.change_key(handle, subkey)
188188
{:ok, values} = :win32reg.values(handle)
189189

190-
case List.keyfind(values, 'Std', 0) do
190+
case List.keyfind(values, ~c"Std", 0) do
191191
{_, zone} when zone == localized -> zone
192192
_ -> nil
193193
end

0 commit comments

Comments
 (0)