gingko / time-distance / Time.Distance.Types

Types to allow you to write your own functions. Note that if you are doing this yourself (instead of importing translations from a server), it'd be helpful if you make a PR or a comment on the repo so I can make the language available for others.

Time.Distance.Types


type DistanceId
    = LessThanXSeconds Basics.Int
    | HalfAMinute
    | LessThanXMinutes Basics.Int
    | XMinutes Basics.Int
    | AboutXHours Basics.Int
    | XDays Basics.Int
    | AboutXMonths Basics.Int
    | XMonths Basics.Int
    | AboutXYears Basics.Int
    | OverXYears Basics.Int
    | AlmostXYears Basics.Int

All available time intervals.


type Tense
    = Past
    | Future

Is this a time in the past, or the future?


type alias Config =
{ withAffix : Basics.Bool }

Should we include affix ("... ago", "in ...")?


type alias Locale =
Config -> Tense -> DistanceId -> String

Main function type : take all the above, return a string.