Simple datejs
A light weight simple date management library
Documentation
Installation
npm i @rnwonder/simple-datejs
yarn add @rnwonder/simple-datejs
pnpm add @rnwonder/simple-datejs
Usage
import { DateMath, utils } from "@rnwonder/simple-datejs";
const today = new Date();
const isToday = utils.checkIfItsTodayDate(today);
const date1 = DateMath.set("2018-03-13");
const date2 = DateMath.set("2017-02-13");
date1.diff(date2);
date1.diff(date2, ["days", "year"]);
const date = { month: 1, day: 14, year: 2023 };
DateMath.set(date).plus({ day: 2 }).toObject();
DateMath.set(date).plus({ day: 2 }).toISO();
DateMath.set(date).plus({ hour: 24, minute: 1440 }).toMillis();
DateMath.set(date).plus({ day: 2 }).toJSDate();
DateMath.set(date).plus({ day: 2 }).toString();
DateMath.set(date)
.plus({ second: 86400 })
.toString({ format: "DDD, MMM dd yyyy" });
DateMath.set(date)
.minus({
year: 2,
month: 2,
day: 2,
hour: 24,
minute: 1440,
second: 86400,
})
.toString({
localeOptions: { dateStyle: "full" },
});
Default imports
import DateMath from "@rnwonder/simple-datejs/dateMath";
import utils from "@rnwonder/simple-datejs/utils";
import { checkIfItsTodayDate } from "@rnwonder/simple-datejs/utils";
Like the library? Give us a star on Github