wojtekmaj / date-utils Goto Github PK
View Code? Open in Web Editor NEWA collection of date-related utilities.
License: MIT License
A collection of date-related utilities.
License: MIT License
Hi there, thanks for the amazing lib.
I would like to add more functions to this library.
https://github.com/leesei/date-utils/commit/a04b82e7ed9b29cbf26b4c018a01650346308443
add ISO/ISO-like strings section
https://www.wikiwand.com/en/ISO_week_date
Will base on implementation in https://stackoverflow.com/a/6117889
Tests will be added with Wiki's data.
Please comment on these API:
getISOWeekNumber(date: Date | string) => number (50)
getISOWeek(date: Date | string) => string ("W50")
getISOWeekDay(date: Date | string) => string ("W504" or "W50-4")
getISOWeekFull(date: Date | string) => string ("2020W50")
getISOWeekDayFull(date: Date | string) => string ("20202020W504" or "20202020W50-4")
/**
* Gets Monday in the same week.
*
* @param {Date} date Date to get Monday from.
* @param {Date} startWithSunday Whether week starts with Sunday
*/
export const getMonday = (date, startWithSunday = false) => {
const dayStartDate = getDayStart(date);
const day = dayStartDate.getDay();
let mondayRel = -(day - 1); // default value
if (day === 0) {
// adjust when day is Sunday
mondayRel = (startWithSunday)? 1 : -6;
}
console.log("Monday is %d days difference", mondayRel);
return getPreviousDayStart(dayStartDate, mondayRel);
};
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.