Git Product home page Git Product logo

dad's Introduction

Why Is Calling Dad?

Dad pronounces like "Date"

Why Use Dad

  • Humans readable code
  • Easy for testing
  • Works in Node and Browser

Installation

$ yarn add github:17media/dad\#latest

Convention

dad's API interface always input seconds and return seconds

Usage

import dad from '@17media/dad'

dad('2017-12-12').tw

// or
import { tw } from '@17media/dad'

tw('2017-12-12')
// 1513036800

tw(1514736000)
// {
//   year: 2018,
//   month: 0,
//   date: 1,
//   hours: 0,
//   minutes: 0,
//   seconds: 0,
//   day: 1
// }

tw(1514736000).format('YYYY/MM/DD hh:mm:ss') //  2018/01/01 00:00:00

Valid date format

  • YYYY-MM-DD
  • YYYY-MM-DD HH
  • YYYY-MM-DD HH:mm
  • YYYY-MM-DD HH:mm:ss

You can omit HH:mm:ss, dad will help you auto suffix 00.

Regions

Current works regions for event:

tw, hk and ja

API

Utils

isToday(seconds)

Check seconds timestamp whether same as Today, this is helpful for vote feature.

now()

now is very useful for testing, you can feel free to hard-code current time.

In Browser, pass URL querystring:

?dad.now=2017-12-12 19:00

In Node:

$ ndoe entry.js --dad.now="2017-12-12 19:00"

pass --auto lets time go on:

In Browser:

?dad.now=2017-12-12 19:00&auto

In Node:

$ ndoe entry.js --dad.now=2017-12-12T19:00 --auto

dad's People

Contributors

gnituy18 avatar rwu823 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dad'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.