mbdavid / utility.js

A set of utility function to work with parse/format Date and Numbers in javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Utility.js

_.parseDate(str)

Parse a string in a valid date pattern on current culture. Returns new Date or null if string was not a valid date

  • str (String) - Date to parse

_.parseNumber(str)

Parse a string in a valid number pattern on current culture. Returns Number or null if string was not a valid number

  • str (String) - Number to parse

_.format(value, fmt)

Format a date, number or string (like String.Format) into a string using current culture. Returns string

  • value (Date|Number|String) - Value to be formated
  • fmt (String) - String format. See:

_.culture(culture)

Get or set object to define current culture. If culture parameter are undefined, returns current culture object

  • culture (Object) - Culture object definition

_.dateAdd(datepart, number, date)

Add period into a date. Returns new Date object

  • datepart (String) - Interval king definition (y, M, d, H, m, s, f)
  • number (Number) - Amouth of interval
  • date (Date) - Date to be added

_.dateDiff(datepart, start, end)

Returns interval (Number) between two dates

  • datepart (String) - Interval definition (y, M, d, H, m, s, f)
  • start (Date) - Inital date
  • end (Date) - Final date

_.timeAgo(date)

Returns human time spend from now to date (returns String)

  • date (Date) - Date to be converted

About

A set of utility function to work with parse/format Date and Numbers in javascript


Languages

Language:JavaScript 87.7%Language:HTML 12.3%