Coder Social home page Coder Social logo

tempus-js's Introduction

TempusJS

JavaScript library for most comfortable using date/time.

Site: http://tempusjs.org/

Install over bower:

    $ bower install tempusjs

Install over npm (after this you can add module as "var tempus = require('tempusjs');"):

    $ npm install tempusjs

Or download some release here https://github.com/crusat/tempus-js/releases

Some Examples

// Returns TempusDate object with current date.
tempus();

// Returns "2013-11-18 20:14:23"
tempus({year: 2013, month: 11, day: 18, hours: 20, minutes: 14,
     seconds: 23, milliseconds: 918}).format('%Y-%m-%d %H:%M:%S');

// Returns TempusDate object with date "2013-11-18 20:15:38"
tempus(1384791338);

// Put date as [year, month, day, hours, minutes, seconds].
tempus([2013, 1, 1, 12, 0, 3]);

// Returns TempusDate object with date 18 November 2013.
tempus('18.11.2013');

// Reformat date, returns '2013-12-15'
tempus('15.12.2013').format('%Y-%m-%d');

// Default date if parsing failed, returns 2013-01-01
tempus('123', '%d.%m.%Y', tempus([2013, 1, 1]));

// VALIDATION

// returns false
tempus('32.08.2013', '%d.%m.%Y').valid();

// returns true
tempus('00:00 01.01.2012', '%H:%M %d.%m.%Y').valid();

// returns {"year":-5,"month":false,"day":false,"hours":false,
//     "minutes":false,"seconds":false,"milliseconds":false}
tempus().year(-5).errors();

// RANGES

// returns 6
tempus([2013, 11, 1]).between(tempus([2014, 5, 5]), 'month');

// returns TempusDate with date 2012-01-01
tempus([2011, 5, 2]).calc({year: 1, month: -4, day: -1});

// DATE GENERATION

// returns ["2013-01-01 00:00","2013-01-02 12:00","2013-01-04 00:00",
//     "2013-01-05 12:00","2013-01-07 00:00","2013-01-08 12:00",
//     "2013-01-10 00:00","2013-01-11 12:00"];
tempus.generateDates({
    dateFrom: '01.01.2013',
    dateTo: '12.01.2013',
    period: {day: 1, hours: 12},
    format: '%Y-%m-%d %H:%M'
});

For more info and examples, please, see documentation

License

MIT

Contact me

[email protected]

tempus-js's People

Contributors

crusat avatar

Stargazers

 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  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

Watchers

 avatar  avatar  avatar

tempus-js's Issues

Time zone list

Names of time zones, transition to summer/winter time and etc.

Add function "translate"

tempus.translate(text); // Example

Also move translations to JSON file and compile version without him.

Date to Array

Returns date as [year, month, day, hours, minutes, seconds, milliseconds]

IE8 error on tests

Died on test #4 undefined: 'registeredFormats[...]' - есть null или не является объектом

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.