GithubHelp home page GithubHelp logo

date.mo's Introduction

Date

Unix time in nanoseconds to/from a Motoko Date object.

Supports conversion to and from ISO 8601 UTC timestamps as well (Text).

Usage

import Date "mo:Date";

// Conversion to and from unix time

let time_ns = 7956912142_222222222;
let date_obj = Date.Date.fromTime(time_ns);

assert( Date.Date.toTime(date_obj) == time_ns );

assert( date_obj == {
                year = 2222; month = 2; day = 22; 
                hour = 21; minute = 22; second = 22;
                nano = 222222222;
            });



// Conversion to and from ISO 8601 UTC Timestamps (Text)

assert( Date.Date.toIsoFormat(date_obj) == "2222-02-22T21:22:22.222Z" );

assert( Date.Date.fromIsoFormat("2222-02-22T21:22:22.000Z") == #ok{
                year = 2222; month = 2; day = 22; 
                hour = 21; minute = 22; second = 22;
                nano = 0;
            } );

date.mo's People

Contributors

mourginakis avatar q-uint avatar

Stargazers

Ethan Celletti avatar Denny Weiß avatar

Watchers

 avatar  avatar

Forkers

ahdrahees

date.mo's Issues

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.