Coder Social home page Coder Social logo

moment-isocalendar's Introduction

moment.isocalendar.js

This plugin provides a Python-like isocalendar method to moment objects.

How to use?

Simply call the isocalendar method on any moment object. It returns an array of four items: year, week_of_year, day_of_week, minutes_since_midnight.

moment(new Date(2011, 11, 23, 14, 30)).isocalendar();
// [2011, 51, 5, 870]

Additionally, there is a function that provides the inverse functionality, it takes an isocalendar array and returns a moment object.

moment.fromIsocalendar([2011, 51, 5, 870]).format('LLLL');
// "Friday, December 23 2011 2:30 PM"

Getters and Setters

This plugin additionally provides getters and setters for the ISO representation values.

var m = moment([2012, 3, 8]); // Sunday, 2012 April 8th

m.isoday(); // 7
m.isoweek(); // 14

m.isoday(6).format('YYYY-MM-DD'); // "2012-04-07"

How to test?

Make sure you have all the dependencies and run make test. If you want to test in the browser, visit the test/test.html file.

moment-isocalendar's People

Contributors

rockymeza avatar

Watchers

James Cloos avatar  avatar

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.