format-date
Advanced tools
Comparing version 0.0.0 to 0.0.1
14
index.js
@@ -9,3 +9,3 @@ var format = require("format-text"); | ||
function formatDate (template, date) { | ||
if (!date) return template; | ||
if (!date) date = new Date; | ||
@@ -20,4 +20,14 @@ return format(template, { | ||
'day-name': days[date.getDay()], | ||
'month-name': months[date.getMonth()] | ||
'month-name': months[date.getMonth()], | ||
// utc | ||
'utc-day': leftpad(date.getUTCDate(), 2, '0'), | ||
'utc-month': leftpad(date.getUTCMonth() + 1, 2, '0'), | ||
'utc-year': date.getUTCFullYear(), | ||
'utc-hours': leftpad(date.getUTCHours(), 2, '0'), | ||
'utc-minutes': leftpad(date.getUTCMinutes(), 2, '0'), | ||
'utc-seconds': leftpad(date.getUTCSeconds(), 2, '0'), | ||
'utc-day-name': days[date.getUTCDay()], | ||
'utc-month-name': months[date.getUTCMonth()] | ||
}); | ||
} |
{ | ||
"name": "format-date", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Takes a string and a date object, returns what you expect", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,3 +16,3 @@ ## format-date | ||
formatDate('{month-name} {year}') | ||
formatDate('{month-name} {year}', new Date) | ||
// => January 2014 | ||
@@ -29,3 +29,2 @@ ``` | ||
```js | ||
* day | ||
@@ -39,2 +38,1 @@ * day-name | ||
* seconds | ||
``` |
2144
27
36