Giter VIP home page Giter VIP logo

date's Introduction

date

This Elm package provides a simple Date type for working with dates without times or zones.

Installation

elm install justinmimbs/date

Overview

Examples

These examples are only meant to give a feel for the library; see the docs for the full API.

Create a date and format it

import Date
import Time exposing (Month(..))

Date.fromCalendarDate 2018 Sep 26
    |> Date.format "EEEE, MMMM ddd, yyyy"
    == "Wednesday, September 26th, 2018"

Find the next Saturday after a date

import Date exposing (Interval(..), Unit(..))
import Time exposing (Month(..))

Date.fromCalendarDate 2018 Sep 26
    |> Date.floor Saturday
    |> Date.add Weeks 1
    |> Date.toIsoString
    == "2018-09-29"

List the third Thursday of the month for six months of a year

import Date exposing (Date, Interval(..), Unit(..))

start : Date
start =
    Date.fromOrdinalDate 2019 1

thirdThursday : Date -> Date
thirdThursday date =
    date |> Date.add Weeks 2 |> Date.ceiling Thursday

Date.range Month 1 start (start |> Date.add Months 6)
    |> List.map thirdThursday
    |> List.map Date.toIsoString
    == [ "2019-01-17"
       , "2019-02-21"
       , "2019-03-21"
       , "2019-04-18"
       , "2019-05-16"
       , "2019-06-20"
       ]

date's People

Contributors

2mol avatar justinmimbs avatar

Watchers

 avatar

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.