1.4.0 • Published 7 years ago

date_utils v1.4.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

date_utils

Consists of date utility functions.

Build Status Coverage Status Dependency Status

Continuous Integration

Currently using travis-ci.org for continuous integration.

Code Coverage

Currently using coveralls.io to provide code coverage badge.

This can be used on the server (nodejs) or the client

The client version of this file can be found at /dist/dateUtils.js To use this version window.__dateUtils

Nodejs Examples

const dateUtils = require('date_utils')

let d = dateUtils('2012-12-01')
d.dateProvided       -> '2012-12-01'
d.asUtc              -> Returns a UTC version of moment object
d.momentDate         -> Moment-ized date object for you to do with what you want
d.ticks              -> valueOf() in Moment
d.standardDateFormat -> '2012-12-01 00:00:00'
d.dateForDisplay     -> '2012-12-01'
d.dateForDisplayFull -> 'December 01, 2012'
d.toDbFormat         -> '2012-12-01T06:00:00.000Z' instance of Date

AddDuration

let d = dateUtils('2012-12-01')
// Acceptable formats +1d, +1m, +1w, +1y ....
d.addDuration() // Defaults to +0d
d.addDuration('+1d') -> same object as above

d.addDuration('+3d').format('YYYY-MM-DD') -> '2012-12-04'

General format method

let d = dateUtils('2012-12-01')
// There exists a general format method which just proxies moment's format
// More info: http://momentjs.com/docs/#/displaying/format/
d.format('YYYY ... MM ... DD') -> '2012 ... 12 ... 01'

#Client Examples

<script type="text/javascript" async src="/dist/dateUtils.js"></script>

var dateUtils = window.__dateUtils;

var d = dateUtils('2012-12-01')
d.dateProvided       -> '2012-12-01'
d.momentDate         -> Moment-ized date object for you to do with what you want
d.ticks              -> valueOf() in Moment
d.standardDateFormat -> '2012-12-01 00:00:00'
d.dateForDisplay     -> '2012-12-01'
d.dateForDisplayFull -> 'December 01, 2012'
d.toDbFormat         -> '2012-12-01T06:00:00.000Z' instance of Date

let d = dateUtils('2012-12-01')
// Acceptable formats +1d, +1m, +1w, +1y ....
d.addDuration() // Defaults to +0d
d.addDuration('+1d') -> same object as above

d.addDuration('+3d').format('YYYY-MM-DD') -> '2012-12-04'
1.4.0

7 years ago

1.3.2

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago