Giter Club home page Giter Club logo

weeks's Introduction

Weeks

怎么安装?

直接复制 src/weeks.js 文件,需要 ES6 支持。

什么功能?

计算某天是第几周,从 1970 年 1 月 1 日算起。

import { weekOfDate } from 'weeks';

// 计算某天是第几周
const today = new Date();
const theWeek = weekOfDate(today);

反过来,计算某周的第一天和最后一天是哪天。默认以星期天为起始日,通过 weeks.setStartOfWeek(1); 设置以星期一为起始日。

import { setStartOfWeek, firstDayOfWeek, lastDayOfWeek } from 'weeks';

// 以星期一为起始日
setStartOfWeek(1);

// 计算第 2048 周的星期一和星期日
const firstDay = firstDayOfWeek(2480);
const lastDay = lastDayOfWeek(2480);

时区因素

weeks 默认使用当地时间计算第几周、第几天。也可通过 weeks.setTimezoneOffsetMS() 更改,具体请参考源码。

weeks's People

Contributors

vale1534 avatar

Watchers

James Cloos 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.