GithubHelp home page GithubHelp logo

d8's Introduction

D8 - The next generation Date object for JavaScript

Description

D8 is a lightweight JavaScript library, that wraps JS's date object and extends it with lots of features that address common use cases when dealing with dates.

Usage

var d1 = new D8(); // var d1 = new ร˜();
var d2 = D8.create('12/31/2011');

d1.format('mm/dd/yyyy');
// 07/28/2011

d2.isLeapYear();
// false

D8.isLeapYear(2012);
// true

d1.getCalendarWeek();
// 30

d1.timeBetween(d2);
// 13423729316

d1.timeBetween(d2, 'days');
// 155

d1.timeBetween(d2, 'days', false);
// 155.3661575810185

var d3 = d1.addHours(12);

d3.format('mm/dd/yyyy');
// 07/29/2011

var d4 = d3.tomorrow();
d4.format('mm/dd/yyyy');
// 07/30/2011

var dates = d1.getDatesOfCalendarWeek();
for(var i = 0; i < dates.length; i++) {
    dates[i].format('mm/dd/yyyy');
}
// 07/24/2011
// 07/25/2011
// 07/26/2011
// 07/27/2011
// 07/28/2011
// 07/29/2011
// 07/30/2011

var d5 = D8.getDateByWeekdayAndCalendarWeek(4, 30, 2011);
d5.format('mm/dd/yyyy');
// 07/28/2011

License

D8 is licensed under the MIT license.

d8's People

Contributors

cowboy avatar josher19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gotomypc

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.