@citation-js/date
Advanced tools
Comparing version 0.4.2 to 0.4.3
@@ -0,1 +1,17 @@ | ||
#### 0.4.3 | ||
##### Fixes | ||
* **output:** | ||
* adapt for node 6 | ||
* support raw dates | ||
##### Tests | ||
* **output:** test formatter | ||
#### 0.4.2 (2018-12-25) | ||
* **npm:** update dependencies | ||
#### 0.4.1 (2018-08-26) | ||
@@ -6,5 +22,5 @@ | ||
* **npm:** update dependencies ([23c0c835](https://github.com/citation-js/date/commit/23c0c8353ffbd4990b942d77d587c733cf8a1514)) | ||
* ***:** require node 6 ([55e09d8c](https://github.com/citation-js/date/commit/55e09d8cb004237bd09c6062905f3ef2c1ccc401)) | ||
* **\*:** require node 6 ([55e09d8c](https://github.com/citation-js/date/commit/55e09d8cb004237bd09c6062905f3ef2c1ccc401)) | ||
### 0.4.0 (2018-07-24) | ||
#### 0.4.0 (2018-07-24) | ||
@@ -16,3 +32,3 @@ ##### Chores | ||
* setup travis-ci ([93b574af](https://github.com/citation-js/date/commit/93b574af2fd6f7c5e8f74aef571b97b15a75b11e)) | ||
* ***:** | ||
* **\*:** | ||
* create index file ([81df1f85](https://github.com/citation-js/date/commit/81df1f85215cf9bbc7853603650641019f80e678)) | ||
@@ -32,2 +48,1 @@ * move files ([510da9c7](https://github.com/citation-js/date/commit/510da9c74a5b7bd8c301f64794793108bdad476f)) | ||
* **input:** setup parsing tests ([ecce8954](https://github.com/citation-js/date/commit/ecce89542a7e2eb1075aa6ee1eddbe07a0d7548f)) | ||
@@ -8,16 +8,26 @@ "use strict"; | ||
const getDate = function getDate({ | ||
'date-parts': [date] | ||
}, delimiter = '-') { | ||
let dateParts = date.map(part => part.toString()); | ||
function padStart(str, len, chr) { | ||
while (str.length < len) { | ||
str = chr + str; | ||
} | ||
return str.slice(-len); | ||
} | ||
const getDate = function getDate(date, delimiter = '-') { | ||
if (!date['date-parts']) { | ||
return date.raw; | ||
} | ||
let dateParts = date['date-parts'][0].map(part => part.toString()); | ||
switch (dateParts.length) { | ||
case 3: | ||
dateParts[2] = dateParts[2].padStart(2, '0'); | ||
dateParts[2] = padStart(dateParts[2], 2, '0'); | ||
case 2: | ||
dateParts[1] = dateParts[1].padStart(2, '0'); | ||
dateParts[1] = padStart(dateParts[1], 2, '0'); | ||
case 1: | ||
dateParts[0] = dateParts[0].padStart(4, '0'); | ||
dateParts[0] = padStart(dateParts[0], 4, '0'); | ||
break; | ||
@@ -24,0 +34,0 @@ } |
{ | ||
"name": "@citation-js/date", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "Date parser and formatter", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10229
205