| 1 |
import { addFormatToken } from '../format/format'; |
| 2 |
import { addRegexToken, matchTimestamp, matchSigned } from '../parse/regex'; |
| 3 |
import { addParseToken } from '../parse/token'; |
| 4 |
import toInt from '../utils/to-int'; |
| 5 |
|
| 6 |
// FORMATTING |
| 7 |
|
| 8 |
addFormatToken('X', 0, 0, 'unix'); |
| 9 |
addFormatToken('x', 0, 0, 'valueOf'); |
| 10 |
|
| 11 |
// PARSING |
| 12 |
|
| 13 |
addRegexToken('x', matchSigned); |
| 14 |
addRegexToken('X', matchTimestamp); |
| 15 |
addParseToken('X', function (input, array, config) { |
| 16 |
config._d = new Date(parseFloat(input) * 1000); |
| 17 |
}); |
| 18 |
addParseToken('x', function (input, array, config) { |
| 19 |
config._d = new Date(toInt(input)); |
| 20 |
}); |