A date formater with caching system for decoded format string
npm install datesThis is date formatter with caching system for decoded format string for Node.JS
javascript
var dates = require('dates');// Format a date without cache using a standard format.
console.log(dates.format(dates.standardFormat.ISO8601), new Date());
// Format a date with cache and custom format.
var formatter = dates.createFormatter("The date is: ddd dd MMMM yyyy - hh:mm:ss.sss $a");
console.log(formatter.format(new Date));
// Format a date with a different local (here french).
formatter = dates.createFormatter("La date est : www dd MMMM yyyy - HH:mm:ss.sss", 'fr');
console.log(formatter.format(new Date));
`` hh: The hour in official 12 hours system (12* for midnight an midday).
HH: The hour in 24 hours system (0* for midnight).
$a: The day period indicator in lower case (am or pm*).
$A: The day period indicator in upper case (AM or PM*).
mm*: The minutes.
ss*: The seconds.
sss*: The milliseconds.
The compiler search two type of element:
* date symbols: referenced previously
* user string: string not recognized
The user string is store as it in the array and the date symbols are converted in formatting functions what
referenced in dictionary.js.
When you call the method format, the array is read to concatenate the user string and the result of **formatting
functions**.
Your original format string is never read again as long you keep the same formatter object.