Skip to content

JolandaNava/time-extra

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

time-extra

Extra functions for working with Posix times from elm/time.

Overview

Examples

See the docs for the full API.

Create a Posix time

import Time exposing (Month(..), utc)
import Time.Extra as Time


Time.Parts 2018 Sep 26 14 30 0 0 |> Time.partsToPosix utc

Find the difference between two Posix times

import Time exposing (Month(..), utc)
import Time.Extra as Time exposing (Interval(..))


time1 = Time.Parts 2020 Sep 1 12 0 0 0 |> Time.partsToPosix utc
time2 = Time.Parts 2020 Sep 4 11 0 0 0 |> Time.partsToPosix utc

Time.diff Day utc time1 time2
    == 2

Create a list of Posix times

import Time exposing (Month(..), utc)
import Time.Extra as Time exposing (Interval(..))


start = Time.Parts 2020 Jan 1 12 0 0 0 |> Time.partsToPosix utc
until = start |> Time.add Day 1 utc

Time.range Hour 4 utc start until
    == List.map (Time.partsToPosix utc)
        [ Time.Parts 2020 Jan 1 12 0 0 0
        , Time.Parts 2020 Jan 1 16 0 0 0
        , Time.Parts 2020 Jan 1 20 0 0 0
        , Time.Parts 2020 Jan 2 0 0 0 0
        , Time.Parts 2020 Jan 2 4 0 0 0
        , Time.Parts 2020 Jan 2 8 0 0 0
        ]

Packages

No packages published

Languages

  • Elm 100.0%