Comparing version 0.2.6 to 0.2.7
# Changelog | ||
## 0.2.7 | ||
* Fix `DateTime.fromMillis(0)` | ||
## 0.2.6 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "luxon", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "Immutable date wrapper", | ||
@@ -5,0 +5,0 @@ "author": "Isaac Cambron", |
@@ -1,3 +0,3 @@ | ||
import { DateTime } from '../datetime'; | ||
import { English } from './english'; | ||
import { Formats } from './formats'; | ||
@@ -16,2 +16,25 @@ function stringifyTokens(splits, tokenToString) { | ||
const tokenToObject = { | ||
D: Formats.DATE_SHORT, | ||
DD: Formats.DATE_MED, | ||
DDD: Formats.DATE_FULL, | ||
DDDD: Formats.DATE_HUGE, | ||
t: Formats.TIME_SIMPLE, | ||
tt: Formats.TIME_WITH_SECONDS, | ||
ttt: Formats.TIME_WITH_SHORT_OFFSET, | ||
tttt: Formats.TIME_WITH_LONG_OFFSET, | ||
T: Formats.TIME_24_SIMPLE, | ||
TT: Formats.TIME_24_WITH_SECONDS, | ||
TTT: Formats.TIME_24_WITH_SHORT_OFFSET, | ||
TTTT: Formats.TIME_24_WITH_LONG_OFFSET, | ||
f: Formats.DATETIME_SHORT, | ||
ff: Formats.DATETIME_MED, | ||
fff: Formats.DATETIME_FULL, | ||
ffff: Formats.DATETIME_HUGE, | ||
F: Formats.DATETIME_SHORT_WITH_SECONDS, | ||
FF: Formats.DATETIME_MED_WITH_SECONDS, | ||
FFF: Formats.DATETIME_FULL_WITH_SECONDS, | ||
FFFF: Formats.DATETIME_HUGE_WITH_SECONDS | ||
}; | ||
/** | ||
@@ -139,2 +162,10 @@ * @private | ||
), | ||
maybeMacro = token => { | ||
const macro = tokenToObject[token]; | ||
if (macro) { | ||
return this.formatWithSystemDefault(dt, macro); | ||
} else { | ||
return token; | ||
} | ||
}, | ||
era = length => | ||
@@ -299,46 +330,4 @@ knownEnglish ? English.eraForDateTime(dt, length) : string({ era: length }, 'era'), | ||
return this.num(dt.ordinal, 3); | ||
// macros | ||
case 'D': | ||
return this.formatWithSystemDefault(dt, DateTime.DATE_SHORT); | ||
case 'DD': | ||
return this.formatWithSystemDefault(dt, DateTime.DATE_MED); | ||
case 'DDD': | ||
return this.formatWithSystemDefault(dt, DateTime.DATE_FULL); | ||
case 'DDDD': | ||
return this.formatWithSystemDefault(dt, DateTime.DATE_HUGE); | ||
case 't': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_SIMPLE); | ||
case 'tt': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_WITH_SECONDS); | ||
case 'ttt': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_WITH_SHORT_OFFSET); | ||
case 'tttt': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_WITH_LONG_OFFSET); | ||
case 'T': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_24_SIMPLE); | ||
case 'TT': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_24_WITH_SECONDS); | ||
case 'TTT': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_24_WITH_SHORT_OFFSET); | ||
case 'TTTT': | ||
return this.formatWithSystemDefault(dt, DateTime.TIME_24_WITH_LONG_OFFSET); | ||
case 'f': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_SHORT); | ||
case 'ff': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_MED); | ||
case 'fff': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_FULL); | ||
case 'ffff': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_HUGE); | ||
case 'F': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_SHORT_WITH_SECONDS); | ||
case 'FF': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_MED_WITH_SECONDS); | ||
case 'FFF': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_FULL_WITH_SECONDS); | ||
case 'FFFF': | ||
return this.formatWithSystemDefault(dt, DateTime.DATETIME_HUGE_WITH_SECONDS); | ||
default: | ||
return token; | ||
return maybeMacro(token); | ||
} | ||
@@ -345,0 +334,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
634118
17452