Giter Club home page Giter Club logo

elm-iso8601's People

Contributors

brian-carroll avatar jweir avatar tom2 avatar

Watchers

 avatar  avatar

elm-iso8601's Issues

What are the implications of removing the Default Values from the internal representation?

Context: jweir#19

Could we replace the existing Model with something that more closely represents the same things as the ISO 8601 spec?

E.g.:

type Model =
    Model Iso8601Base

type alias Iso8601Base =
    { offsetInMinutes : Maybe Int
    , date : Iso8601DateOption
    , time : Maybe Iso8601TimeOption
    }

{-| Note that a "Year" may differ based on the representation.
For example, 2019-12-30 and 2020-W01-01 are the same date.

So while all members of this sum type share a Year, they're not
freely interchangeable.
-}
type Iso8601DateOption
    = YearMonthDay Int Int Int -- 1999-12-31
    | Year Int -- 1999
    | YearWeek Int Int -- 1999-W52
    | YearWeekDay Int Int Int -- 1999-W52-7
    | YearOrdinal Int Int -- 1999-354


type Iso8601TimeOption
    = Hour Int (Maybe Float) -- 09, 09.5
    | HourMinute Int Int (Maybe Float) -- 09:59, 09:59.5
    | HourMinuteSecond Int Int Int (Maybe Float) -- 09:59:59, 09:59:59.999

Model isn't an opaque type, so immediately there'll be a major version bump.

Would it necessarily mean a large amount of work? For those relying on the default values, would a function like Model -> {offset: Int, seconds:Int, ...} be enough?

Other parts of ISO 8601 to consider

  • Durations
  • Time intervals
  • Repeating intervals

Precedents

.Net apparently had a similar situation with their DateTime type, which they addressed by adding a three-state "Kind" (either Local, UTC, or Unknown) to the existing type, and creating a new DateTimeOffset type which enforces Absolute (un-ambiguous) times.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.