Skip to content

Commit

Permalink
Fix compiler warnings for Elixir 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed May 29, 2024
1 parent ed25e65 commit a67e8bb
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 39 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Changelog

**Note that `ex_cldr_dates_times` version 2.14.0 and later are supported on Elixir 1.11 and later only.**
**Note that `ex_cldr_dates_times` version 2.18.0 and later are supported on Elixir 1.12 and later only.**

## Cldr_Dates_Times v2.18.0

This is the changelog for Cldr_Dates_Times v2.18.0 released on May 29th, 2024. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_cldr_dates_times/tags)

### Bug Fixes

* Clarify format compiler documentation. Thanks to @tjchambers for the issue. Closes #46.

* Fix typos. Thanks to @tjchambers for the PR. Closes #47.

## Cldr_Dates_Times v2.17.1

Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/backend/compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule Cldr.DateTime.Compiler do
## Returns
A list of 3-tuples which represent the tokens
of the format definition
of the format definition.
## Example
Expand Down
56 changes: 28 additions & 28 deletions lib/cldr/backend/interval.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,31 +232,31 @@ defmodule Cldr.Interval.Backend do
## Examples
iex> #{inspect(__MODULE__)}.to_string ~D[2020-01-01], ~D[2020-12-31]
iex> #{inspect(__MODULE__)}.to_string(~D[2020-01-01], ~D[2020-12-31])
{:ok, "Jan 1 – Dec 31, 2020"}
iex> #{inspect(__MODULE__)}.to_string ~D[2020-01-01], ~D[2020-01-12]
iex> #{inspect(__MODULE__)}.to_string(~D[2020-01-01], ~D[2020-01-12])
{:ok, "Jan 1 – 12, 2020"}
iex> #{inspect(__MODULE__)}.to_string ~D[2020-01-01], ~D[2020-01-12],
...> format: :long
iex> #{inspect(__MODULE__)}.to_string(~D[2020-01-01], ~D[2020-01-12],
...> format: :long)
{:ok, "Wed, Jan 1 – Sun, Jan 12, 2020"}
iex> #{inspect(__MODULE__)}.to_string ~D[2020-01-01], ~D[2020-12-01],
...> format: :long, style: :year_and_month
iex> #{inspect(__MODULE__)}.to_string(~D[2020-01-01], ~D[2020-12-01],
...> format: :long, style: :year_and_month)
{:ok, "January – December 2020"}
iex> use CalendarInterval
iex> #{inspect(__MODULE__)}.to_string ~I"2020-01-01/12",
...> format: :long
iex> #{inspect(__MODULE__)}.to_string(~I"2020-01-01/12",
...> format: :long)
{:ok, "Wed, Jan 1 – Sun, Jan 12, 2020"}
iex> #{inspect(__MODULE__)}.to_string ~U[2020-01-01 00:00:00.0Z], ~U[2020-12-01 10:05:00.0Z],
...> format: :long
iex> #{inspect(__MODULE__)}.to_string(~U[2020-01-01 00:00:00.0Z], ~U[2020-12-01 10:05:00.0Z],
...> format: :long)
{:ok, "January 1, 2020, 12:00:00 AM UTC – December 1, 2020, 10:05:00 AM UTC"}
iex> #{inspect(__MODULE__)}.to_string ~U[2020-01-01 00:00:00.0Z], ~U[2020-01-01 10:05:00.0Z],
...> format: :long
iex> #{inspect(__MODULE__)}.to_string(~U[2020-01-01 00:00:00.0Z], ~U[2020-01-01 10:05:00.0Z],
...> format: :long)
{:ok, "January 1, 2020, 12:00:00 AM UTC – 10:05:00 AM UTC"}
"""
Expand Down Expand Up @@ -364,12 +364,12 @@ defmodule Cldr.Interval.Backend do
## Examples
iex> use CalendarInterval
iex> #{inspect(__MODULE__)}.to_string! ~I"2020-01-01/12",
...> format: :long
iex> #{inspect(__MODULE__)}.to_string!(~I"2020-01-01/12",
...> format: :long)
"Wed, Jan 1 – Sun, Jan 12, 2020"
iex> #{inspect(__MODULE__)}.to_string! Date.range(~D[2020-01-01], ~D[2020-12-31]),
...> format: :long
iex> #{inspect(__MODULE__)}.to_string!(Date.range(~D[2020-01-01], ~D[2020-12-31]),
...> format: :long)
"Wed, Jan 1 – Thu, Dec 31, 2020"
"""
Expand Down Expand Up @@ -475,31 +475,31 @@ defmodule Cldr.Interval.Backend do
## Examples
iex> #{inspect(__MODULE__)}.to_string! ~D[2020-01-01], ~D[2020-12-31]
iex> #{inspect(__MODULE__)}.to_string!(~D[2020-01-01], ~D[2020-12-31])
"Jan 1 – Dec 31, 2020"
iex> #{inspect(__MODULE__)}.to_string! ~D[2020-01-01], ~D[2020-01-12]
iex> #{inspect(__MODULE__)}.to_string!(~D[2020-01-01], ~D[2020-01-12])
"Jan 1 – 12, 2020"
iex> #{inspect(__MODULE__)}.to_string! ~D[2020-01-01], ~D[2020-01-12],
...> format: :long
iex> #{inspect(__MODULE__)}.to_string!(~D[2020-01-01], ~D[2020-01-12],
...> format: :long)
"Wed, Jan 1 – Sun, Jan 12, 2020"
iex> #{inspect(__MODULE__)}.to_string! ~D[2020-01-01], ~D[2020-12-01],
...> format: :long, style: :year_and_month
iex> #{inspect(__MODULE__)}.to_string!(~D[2020-01-01], ~D[2020-12-01],
...> format: :long, style: :year_and_month)
"January – December 2020"
iex> use CalendarInterval
iex> #{inspect(__MODULE__)}.to_string! ~I"2020-01-01/12",
...> format: :long
iex> #{inspect(__MODULE__)}.to_string!(~I"2020-01-01/12",
...> format: :long)
"Wed, Jan 1 – Sun, Jan 12, 2020"
iex> #{inspect(__MODULE__)}.to_string! ~U[2020-01-01 00:00:00.0Z], ~U[2020-12-01 10:05:00.0Z],
...> format: :long
iex> #{inspect(__MODULE__)}.to_string!(~U[2020-01-01 00:00:00.0Z], ~U[2020-12-01 10:05:00.0Z],
...> format: :long)
"January 1, 2020, 12:00:00 AM UTC – December 1, 2020, 10:05:00 AM UTC"
iex> #{inspect(__MODULE__)}.to_string! ~U[2020-01-01 00:00:00.0Z], ~U[2020-01-01 10:05:00.0Z],
...> format: :long
iex> #{inspect(__MODULE__)}.to_string!(~U[2020-01-01 00:00:00.0Z], ~U[2020-01-01 10:05:00.0Z],
...> format: :long)
"January 1, 2020, 12:00:00 AM UTC – 10:05:00 AM UTC"
"""
Expand Down
6 changes: 3 additions & 3 deletions lib/cldr/interval/date.ex
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ defmodule Cldr.Date.Interval do
{:ok, locale} <- Cldr.validate_locale(locale, backend),
{:ok, _} <- Cldr.Number.validate_number_system(locale, number_system, backend),
{:ok, calendar} <- Cldr.Calendar.validate_calendar(from.calendar),
{:ok, formats} <- Format.interval_formats(locale, calendar.cldr_calendar_type, backend),
{:ok, formats} <- Format.interval_formats(locale, calendar.cldr_calendar_type(), backend),
{:ok, [left, right]} <- resolve_format(from, to, formats, options),
{:ok, left_format} <- formatter.format(from, left, locale, options),
{:ok, right_format} <- formatter.format(to, right, locale, options) do
Expand All @@ -413,7 +413,7 @@ defmodule Cldr.Date.Interval do
# Open ended intervals use the `date_time_interval_fallback/0` format
def to_string(nil, unquote(date()) = to, backend, options) do
{locale, backend} = Cldr.locale_and_backend_from(options[:locale], backend)
cldr_calendar = calendar.cldr_calendar_type
cldr_calendar = calendar.cldr_calendar_type()

with {:ok, formatted} <- Cldr.Date.to_string(to, backend, options) do
pattern = Module.concat(backend, DateTime.Format).date_time_interval_fallback(locale, cldr_calendar)
Expand All @@ -429,7 +429,7 @@ defmodule Cldr.Date.Interval do

def to_string(unquote(date()) = from, nil, backend, options) do
{locale, backend} = Cldr.locale_and_backend_from(options[:locale], backend)
cldr_calendar = calendar.cldr_calendar_type
cldr_calendar = calendar.cldr_calendar_type()

with {:ok, formatted} <- Cldr.Date.to_string(from, backend, options) do
pattern = Module.concat(backend, DateTime.Format).date_time_interval_fallback(locale, cldr_calendar)
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/interval/date_time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ defmodule Cldr.DateTime.Interval do
# Open ended intervals use the `date_time_interval_fallback/0` format
def to_string(nil, unquote(naivedatetime()) = to, backend, options) do
{locale, backend} = Cldr.locale_and_backend_from(options[:locale], backend)
cldr_calendar = calendar.cldr_calendar_type
cldr_calendar = calendar.cldr_calendar_type()

with {:ok, formatted} <- Cldr.DateTime.to_string(to, backend, options) do
pattern = Module.concat(backend, DateTime.Format).date_time_interval_fallback(locale, cldr_calendar)
Expand All @@ -368,7 +368,7 @@ defmodule Cldr.DateTime.Interval do

def to_string(unquote(naivedatetime()) = from, nil, backend, options) do
{locale, backend} = Cldr.locale_and_backend_from(options[:locale], backend)
cldr_calendar = calendar.cldr_calendar_type
cldr_calendar = calendar.cldr_calendar_type()

with {:ok, formatted} <- Cldr.DateTime.to_string(from, backend, options) do
pattern = Module.concat(backend, DateTime.Format).date_time_interval_fallback(locale, cldr_calendar)
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/interval/time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ defmodule Cldr.Time.Interval do
{:ok, locale} <- Cldr.validate_locale(locale, backend),
{:ok, _} <- Cldr.Number.validate_number_system(locale, number_system, backend),
{:ok, calendar} <- Cldr.Calendar.validate_calendar(from.calendar),
{:ok, formats} <- Format.interval_formats(locale, calendar.cldr_calendar_type, backend),
{:ok, formats} <- Format.interval_formats(locale, calendar.cldr_calendar_type(), backend),
{:ok, [left, right]} <- resolve_format(from, to, formats, locale, options),
{:ok, left_format} <- formatter.format(from, left, locale, options),
{:ok, right_format} <- formatter.format(to, right, locale, options) do
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Cldr.DatesTimes.Mixfile do
use Mix.Project

@version "2.17.1"
@version "2.18.0"

def project do
[
Expand All @@ -10,7 +10,7 @@ defmodule Cldr.DatesTimes.Mixfile do
name: "Cldr Dates & Times",
source_url: "https://github.com/elixir-cldr/cldr_dates_times",
docs: docs(),
elixir: "~> 1.11",
elixir: "~> 1.12",
description: description(),
package: package(),
start_permanent: Mix.env() == :prod,
Expand Down
2 changes: 1 addition & 1 deletion test/interval_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule Cldr.DateTime.Interval.Test do
) ==
{:error,
{Cldr.DateTime.Compiler.ParseError,
"Could not tokenize \"unk\". Error detected at " <> inspect('n')}}
"Could not tokenize \"unk\". Error detected at " <> inspect([?n])}}

assert Cldr.Date.Interval.to_string(Date.range(~D[2020-01-01], ~D[2020-01-12]), MyApp.Cldr,
format: :unknown
Expand Down

0 comments on commit a67e8bb

Please sign in to comment.