Git Product home page Git Product logo

mmwr-week's Introduction

mmwr-week npm

Tiny port of MMWRWeek to TypeScript. Weekdays go from Sunday (1) to Saturday (7). Read full documentation here.

npm install mmwr-week
 const mmwr = require('mmwr-week')
 const moment = require('moment')

// Create MMWRDate object
 let mdate = new mmwr.MMWRDate(2016, 48)
// MMWRDate { year: 2016, week: 48, day: undefined }

// First day of year according to MMWRDate
 mdate.startMomentDate
// returns moment("2016-01-03T00:00:00.000")

// Convert to moment object
 mdate.toMomentDate()
// returns moment("2016-11-27T00:00:00.000")

// Moment date to MMWRDate
 mdate.fromMomentDate(moment('2016-12-27'))
// returns nothing, mutates mdate to MMWRDate { year: 2016, week: 52, day: 3 }

// Convert to JS Date
 mdate.toJSDate()
// returns 2016-12-27T05:00:00.000Z

// JS Date to MMWRDate
 mdate.fromJSDate(new Date('2016-12-27T05:00:00.000Z'))
// returns nothing, mutates mdate

// Convert to epiweek
 mdate.toEpiweek()
// returns 201652

// Import from epiweek
 mdate.fromEpiweek(201732)
// returns nothing, mutates mdate to MMWRDate { year: 2017, week: 32, day: 1 }

// Number of MMWR weeks in a year
 mdate.nWeeks
// returns 52

// Week difference (mdate - odate)
 let odate = new mmwr.MMWRDate(2016, 3)
 mdate.diffWeek(odate)
// returns 81

// Apply week diff
 mdate.applyWeekDiff(56)
// returns nothing, mutates mdate to MMWRDate { year: 2018, week: 36, day: 1 }

mmwr-week's People

Watchers

 avatar  avatar  avatar

Forkers

lijiezhang1998

mmwr-week'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.