Skip to content

PseudoMera/date-parser

Repository files navigation

Pseudo Date Parser

Utility to help you transform your dates into a comprehensive format.

Getting Started

Installing

$ npm i @pseudomera/date-parser

How to use it

  1. We import the package
import PseudoDateParser from "@pseudomera/date-parser/dist/dateParser"
  1. 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")
  2. 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}`
    );

Available properties

  day: string;
  month: string;
  year: string;
  dayOfTheWeek: string;
  hour: string;
  minutes: string;
  seconds: string;
  miliseconds: string;
  amOrPm: string;
  monthNumber: string;
  monthShort: string;

Built With

Contributing

Just open a pull request or issue.

Versioning

We use SemVer for versioning.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details