Last active
June 27, 2018 18:11
-
-
Save ckhrysze/b9ef3805663be6817de23d8db7c18450 to your computer and use it in GitHub Desktop.
Timex between? example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Test436 do | |
def test do | |
IO.puts("Testing Daylight Savings issue 436") | |
# demonstrate both styles of creating elixir time structs | |
start = ~T[09:00:00] | |
{:ok, stop} = Time.new(12, 0, 0) | |
# will be true when the current time is between 9am and noon in | |
# los angeles and anywhere else in the same timezone, with respect to | |
# the olson database which tracks timezone and daylight savings data | |
Timex.now("America/Los_Angeles") | |
|> DateTime.to_time() | |
|> Timex.between?(start, stop) | |
|> IO.inspect() | |
# will be true when the current time is between 9am and noon in | |
# Hawaii, which has not observed daylight savings since 1945 | |
Timex.now("Pacific/Honolulu") | |
|> DateTime.to_time() | |
|> Timex.between?(start, stop) | |
|> IO.inspect() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment