finos / morphir-elm / Morphir.SDK.LocalDate

This module adds the definition of a date without time zones. Useful in business modeling.

Types


type alias LocalDate =
Date

Concept of a date without time zones.

Date Math

diffInDays : LocalDate -> LocalDate -> Basics.Int

Find the number of days between the given dates.

diffInWeeks : LocalDate -> LocalDate -> Basics.Int

Find the number of weeks between the given dates.

diffInMonths : LocalDate -> LocalDate -> Basics.Int

Find the number of months between the given dates.

diffInYears : LocalDate -> LocalDate -> Basics.Int

Find the number of years between the given dates.

addDays : Basics.Int -> LocalDate -> LocalDate

Add the given days to a given date.

addWeeks : Basics.Int -> LocalDate -> LocalDate

Add the given weeks to a given date.

addMonths : Basics.Int -> LocalDate -> LocalDate

Add the given months to a given date.

addYears : Basics.Int -> LocalDate -> LocalDate

Add the given years to a given date.

Constructors

fromCalendarDate : Basics.Int -> Month -> Basics.Int -> LocalDate

Create a date from a calendar date: a year, month, and day of the month. Out-of-range day values will be clamped.

import Morphir.SDK.LocalDate exposing (fromCalendarDate, Month(..))

fromCalendarDate 2018 September 26

fromISO : String -> Maybe LocalDate

Construct a LocalDate based on ISO formatted string. Opportunity for error denoted by Maybe return type.

fromOrdinalDate : Basics.Int -> Basics.Int -> LocalDate

Create a date from an ordinal date: a year and day of the year. Out-of-range day values will be clamped.

import Morphir.SDK.LocalDate exposing (fromOrdinalDate)

fromOrdinalDate 2018 269

fromParts : Basics.Int -> Basics.Int -> Basics.Int -> Maybe LocalDate

Construct a LocalDate based on Year, Month, Day. Opportunity for error denoted by Maybe return type. Errors can occur when any of the given values fall outside of their relevant constraints. For example, the date given as 2000 2 30 (2000-Feb-30) would fail because the day of the 30th is impossible.

Convert

toISOString : LocalDate -> String

Convert a LocalDate to a string in ISO format.

monthToInt : Month -> Basics.Int

Converts a Month to an Int, where January is month 1 and December is month 12.

Query


type DayOfWeek
    = Monday
    | Tuesday
    | Wednesday
    | Thursday
    | Friday
    | Saturday
    | Sunday

Type that represents a day of the week.

dayOfWeek : LocalDate -> DayOfWeek

Returns the day of week for a date.

isWeekend : LocalDate -> Basics.Bool

Returns true if the date falls on a weekend (Saturday or Sunday).

isWeekday : LocalDate -> Basics.Bool

Returns true if the date falls on a weekday (any day other than Saturday or Sunday).


type Month
    = January
    | February
    | March
    | April
    | May
    | June
    | July
    | August
    | September
    | October
    | November
    | December

Gregorian calendar months in English.

year : LocalDate -> Basics.Int

Returns the year as a number.

month : LocalDate -> Month

Returns the month of the year for a given date.

monthNumber : LocalDate -> Basics.Int

Returns the month of the year as an Int, where January is month 1 and December is month 12.

day : LocalDate -> Basics.Int

The day of the month (1–31).