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