@appstractdk/as-date-utils

1.1.23 • Public • Published

as-date-utils

does date manipulation and formatting

Functionality

DateUtils class contains the following methods:

  • formatDate(date_object, format_string) - returns a date in the specified format.
  • getDateFromFormat(date_string , format_string) - if the date string matches the format string, it returns the getTime() of the date; if it does not match, it returns 0.
  • parseDate(date_string [, prefer_euro_format]) - takes a date string and tries to match it to a number of possible date formats to get the value. A second argument may be passed to instruct the method to search for formats like d/M/y (european format) before M/d/y (American). Returns a Date object or null if no patterns match.
  • isDate(date_string, format_string) - returns true if date string matches format and is a valid date, otherwise returns false.
  • compareDates(date1,date1format,date2,date2format) - compares two date strings to see which is greater. Returns:
    • 1 if date1 is greater than date2
    • 0 if date2 is greater than date1 of if they are the same
    • -1 if either of the dates is in an invalid format
  • secondsToDate(seconds, format) - returns a string representing the date given in seconds.
  • utcSeconds() - returns UTC in seconds.
  • utcMiliseconds() - returns UTC in milliseconds.
  • dateToSeconds(string, format) - returns a date in seconds as specified by the given string.
  • timeToSeconds(string) - returns specified string as seconds.

Readme

Keywords

none

Package Sidebar

Install

npm i @appstractdk/as-date-utils

Weekly Downloads

1

Version

1.1.23

License

ISC

Unpacked Size

36.9 kB

Total Files

7

Last publish

Collaborators

  • appstract-team
  • raulstefan
  • ioanagrozav
  • mebappstract