Skip to content

Commit

Permalink
Allow leap seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
DevL committed Jun 17, 2016
1 parent 3108ada commit 5be05ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/guardsafe.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Guardsafe do
@vsn "0.5.0"
@vsn "0.5.1"
@doc false
def version, do: @vsn

Expand Down Expand Up @@ -139,7 +139,8 @@ defmodule Guardsafe do
Returns true if the term is considered to be a time tuple.
The time is not checked for validity other than the hours being in
the 0..23 range and the minutes and seconds being in the 0..59 range.
the 0..23 range, the minutes being in the 0..59 range, and seconds
being in the 0..60 range. The latter due to the existance of leap seconds.
## Examples
Expand All @@ -155,7 +156,7 @@ defmodule Guardsafe do
and is_integer(elem(unquote(term), 1))
and (elem(unquote(term), 1) |> within?(0, 59))
and is_integer(elem(unquote(term), 2))
and (elem(unquote(term), 2) |> within?(0, 59))
and (elem(unquote(term), 2) |> within?(0, 60))
end
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Guardsafe.Mixfile do
def project do
[
app: :guardsafe,
version: "0.5.0",
version: "0.5.1",
name: "Guardsafe",
source_url: "https://github.com/DevL/guardsafe",
homepage_url: "https://hex.pm/packages/guardsafe",
Expand Down
5 changes: 3 additions & 2 deletions test/guardsafe_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ defmodule GuardsafeTest do
test "time?" do
assert When.using_time?({0, 0, 0})
assert When.using_time?({23, 59, 59})
assert When.using_time?({23, 59, 60})
refute When.using_time?({23, 60, 59})
refute When.using_time?({23, 59, 60})
refute When.using_time?({23, 59, 61})
refute When.using_time?({24, 0, 0})
refute When.using_time?({-1, 0, 0})
refute When.using_time?({12, 15})
Expand All @@ -149,7 +150,7 @@ defmodule GuardsafeTest do
test "datetime?" do
assert When.using_datetime?({{2015, 3, 14}, {21, 49, 52}})
refute When.using_datetime?({{2015, 13, 14}, {21, 49, 52}})
refute When.using_datetime?({{2015, 3, 14}, {23, 59, 60}})
refute When.using_datetime?({{2015, 3, 14}, {23, 59, 61}})
refute When.using_datetime?({{2015, 3, 14}, {23, 59}})
refute When.using_datetime?({2015, 3, 14})
end
Expand Down

0 comments on commit 5be05ad

Please sign in to comment.