rluiten/elm-date-extra/9.2.2

NOTE: this package is not compatible with Elm 0.19.1

Date.Extra.Field

Setting a date field on a date.

fieldToDate : Field -> Date -> Maybe Date

Set a field on a date to a specific value.

If your value in field is out side of valid range for the date field this function will return Nothing.

  • DayOfWeek cannot be invalid input range
  • Month cannot be invalid

Valid ranges

  • Millisecond 0 to 999
  • Second 0 to 59
  • Minute 0 to 59
  • Hour 0 to 23
  • DayOfMonth 1 to max day of month for year
  • Year >= 0
fieldToDateClamp : Field -> Date -> Date

Set a field on a date to a specific value.

This version clamps any input Field values to valid ranges as described in the doc for fieldToDate function.

type Field
= Millisecond Int
| Second Int
| Minute Int
| Hour Int
| DayOfWeek ( Day, Day )
| DayOfMonth Int
| Month Month
| Year Int

Configured Field and Value to set on date.

All field values are applied Modulus there maximum value.

  • DayOfWeek
    • The week keeps the same start of week day as passed in and changes day.
  • Month
    • Will not change year only the month of year.

Copyright (c) 2016-2017 Robin Luiten