Utility to help you transform your dates into a comprehensive format.
$ npm i @pseudomera/date-parser
- We import the package
import PseudoDateParser from "@pseudomera/date-parser/dist/dateParser"
-
We can pass a number, date or a valid date string (e.g an ISO string)
//If you are using unix date format, e.g. 1610814996, It needs to be a number //If you pass it as a string it will fail. const parsedDate = PseudoDateParser(new Date(1610814996)) const parsedDate = PseudoDateParser(new Date()) const parsedNumber = PseudoDateParser(2) const parsedISOString = PseudoDateParser("2007-03-01T13:00:00Z")
-
We use our parsed data!
console.log(
`${parsedDate.dayOfTheWeek} ${parsedDate.monthNumber} ${parsedDate.month} ${parsedDate.year}`
);
console.log(
`${parsedNumber.dayOfTheWeek} ${parsedNumber.monthNumber} ${parsedNumber.month} ${parsedNumber.year}`
);
console.log(
`${parsedISOString.dayOfTheWeek} ${parsedISOString.monthNumber} ${parsedISOString.month} ${parsedISOString.year}`
);
day: string;
month: string;
year: string;
dayOfTheWeek: string;
hour: string;
minutes: string;
seconds: string;
miliseconds: string;
amOrPm: string;
monthNumber: string;
monthShort: string;
- date-fns - Modern Javascript date utility library
- typescript - Typed Javascript
Just open a pull request or issue.
We use SemVer for versioning.
- Albin Frias - PseudoMera
This project is licensed under the MIT License - see the LICENSE.md file for details