Library for working with time and time zones.
You should not use the Time module with TEPA because the functions that the module exposes cannot recognize the emulated time lapse during Scenario testing.
Block progress on the current procedure for the given number of milliseconds. The JavaScript equivalent of this is setTimeout which lets you delay work until later.
This is the TEPA version of Process.sleep.
Get the POSIX time at the moment when this Promise is evaluated.
This is the TEPA version of Time.now.
Get the current time periodically at the specified interval in milliseconds (like 1000 for a second or 60 * 1000 for a minute or 60 * 60 * 1000 for an hour).
This is the TEPA version of Time.every.
Similar to every, but returns Stream.
The Stream produces current time periodically at the specified interval in milliseconds (like 1000 for a second or 60 * 1000 for a minute or 60 * 60 * 1000 for an hour).
Same as Time.posixToMillis.
Turn a Posix time into the number of milliseconds since 1970 January 1
at 00:00:00 UTC. It was a Thursday.
Same as Time.millisToPosix.
Turn milliseconds into a Posix time.
Alias for Time.Zone.
Information about a particular time zone.
Refer to the Time.utc documentation for more detailed notes.
See utc, here, and Browser.Env to learn how to
obtain Zone values.
Alias for Time.utc.
The time zone for Coordinated Universal Time ([UTC])
Refer to the Time.utc documentation for more detailed notes.
Produce a Zone based on the current UTC offset. You can use this to figure
out what day it is where you are:
import Tepa exposing (Promise)
import Tepa.Time as Time
whatDayIsIt : Promise m Int
whatDayIsIt =
Tepa.suceed Time.toDay
|> Tepa.sync Time.here
|> Tepa.sync Time.nowRefer to the Time.here documentation for more detailed notes.
This is the TEPA version of here.
Alias for Time.toYear.
What year is it?!
import Tepa.Time exposing (toYear, utc, millisToPosix)
toYear utc (millisToPosix 0) == 1970
toYear nyc (millisToPosix 0) == 1969
-- pretend `nyc` is the `Zone` for America/New_York.Alias for Time.toMonth.
What month is it?!
import Tepa.Time exposing (toMonth, utc, millisToPosix)
toMonth utc (millisToPosix 0) == Jan
toMonth nyc (millisToPosix 0) == Dec
-- pretend `nyc` is the `Zone` for America/New_York.Alias for Time.toDay.
What day is it?! (Days go from 1 to 31)
import Tepa.Time exposing (toDay, utc, millisToPosix)
toDay utc (millisToPosix 0) == 1
toDay nyc (millisToPosix 0) == 31
-- pretend `nyc` is the `Zone` for America/New_York.What day of the week is it?
import Tepa.Time exposing (toWeekday, utc, millisToPosix)
toWeekday utc (millisToPosix 0) == Thu
toWeekday nyc (millisToPosix 0) == Wed
-- pretend `nyc` is the `Zone` for America/New_York.This is the TEPA version of Time.toWeekday.
Alias for Time.toHour.
What hour is it? (From 0 to 23)
import Tepa.Time exposing (toHour, utc, millisToPosix)
toHour utc (millisToPosix 0) == 0 -- 12am
toHour nyc (millisToPosix 0) == 19 -- 7pm
-- pretend `nyc` is the `Zone` for America/New_York.Alias for Time.toMinute.
What minute is it? (From 0 to 59)
import Tepa.Time exposing (toMinute, utc, millisToPosix)
toMinute utc (millisToPosix 0) == 0This can be different in different time zones. Some time zones are offset by 30 or 45 minutes!
Alias for Time.toSecond.
What second is it?
import Time exposing (toSecond, utc, millisToPosix)
toSecond utc (millisToPosix 0) == 0
toSecond utc (millisToPosix 1234) == 1
toSecond utc (millisToPosix 5678) == 5Alias for Time.toMillis.
import Tepa.Time exposing (toMillis, utc, millisToPosix)
toMillis utc (millisToPosix 0) == 0
toMillis utc (millisToPosix 1234) == 234
toMillis utc (millisToPosix 5678) == 678Represents a Weekday so that you can convert it to a String or Int
however you please. For example, if you need the Japanese representation, you
can say:
toJapaneseWeekday : Weekday -> String
toJapaneseWeekday weekday =
case weekday of
Mon ->
"月"
Tue ->
"火"
Wed ->
"水"
Thu ->
"木"
Fri ->
"金"
Sat ->
"土"
Sun ->
"日"This is the TEPA version of Time.Weekday.
Represents a Month so that you can convert it to a String or Int
however you please. For example, if you need the Danish representation, you
can say:
toDanishMonth : Month -> String
toDanishMonth month =
case month of
Jan ->
"januar"
Feb ->
"februar"
Mar ->
"marts"
Apr ->
"april"
May ->
"maj"
Jun ->
"juni"
Jul ->
"juli"
Aug ->
"august"
Sep ->
"september"
Oct ->
"oktober"
Nov ->
"november"
Dec ->
"december"This is the TEPA version of Time.Month.
Alias for
Time.Posix.A computer representation of time. It is the same all over Earth, so if we have a phone call or meeting at a certain POSIX time, there is no ambiguity.
It is very hard for humans to read a POSIX time though, so we use functions like
toHourandtoMinutetoviewthem.