vendor: 4,778 bytes, lines 1-134
1import { int, pad } from "../utils/index.js"; 2var doNothing = function () { return undefined; }; 3export var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; }; 4export var revFormat = { 5 D: doNothing, 6 F: function (dateObj, monthName, locale) { 7 dateObj.setMonth(locale.months.longhand.indexOf(monthName)); 8 }, 9 G: function (dateObj, hour) { 10 dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour)); 11 }, 12 H: function (dateObj, hour) { 13 dateObj.setHours(parseFloat(hour)); 14 }, 15 J: function (dateObj, day) { 16 dateObj.setDate(parseFloat(day)); 17 }, 18 K: function (dateObj, amPM, locale) { 19 dateObj.setHours((dateObj.getHours() % 12) + 20 12 * int(new RegExp(locale.amPM[1], "i").test(amPM))); 21 }, 22 M: function (dateObj, shortMonth, locale) { 23 dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth)); 24 }, 25 S: function (dateObj, seconds) { 26 dateObj.setSeconds(parseFloat(seconds)); 27 }, 28 U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); }, 29 W: function (dateObj, weekNum, locale) { 30 var weekNumber = parseInt(weekNum); 31 var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0); 32 date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek); 33 return date; 34 }, 35 Y: function (dateObj, year) { 36 dateObj.setFullYear(parseFloat(year)); 37 }, 38 Z: function (_, ISODate) { return new Date(ISODate); }, 39 d: function (dateObj, day) { 40 dateObj.setDate(parseFloat(day)); 41 }, 42 h: function (dateObj, hour) { 43 dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour)); 44 }, 45 i: function (dateObj, minutes) { 46 dateObj.setMinutes(parseFloat(minutes)); 47 }, 48 j: function (dateObj, day) { 49 dateObj.setDate(parseFloat(day)); 50 }, 51 l: doNothing, 52 m: function (dateObj, month) { 53 dateObj.setMonth(parseFloat(month) - 1); 54 }, 55 n: function (dateObj, month) { 56 dateObj.setMonth(parseFloat(month) - 1); 57 }, 58 s: function (dateObj, seconds) { 59 dateObj.setSeconds(parseFloat(seconds)); 60 }, 61 u: function (_, unixMillSeconds) { 62 return new Date(parseFloat(unixMillSeconds)); 63 }, 64 w: doNothing, 65 y: function (dateObj, year) { 66 dateObj.setFullYear(2000 + parseFloat(year)); 67 }, 68}; 69export var tokenRegex = { 70 D: "", 71 F: "", 72 G: "(\\d\\d|\\d)", 73 H: "(\\d\\d|\\d)", 74 J: "(\\d\\d|\\d)\\w+", 75 K: "", 76 M: "", 77 S: "(\\d\\d|\\d)", 78 U: "(.+)", 79 W: "(\\d\\d|\\d)", 80 Y: "(\\d{4})", 81 Z: "(.+)", 82 d: "(\\d\\d|\\d)", 83 h: "(\\d\\d|\\d)", 84 i: "(\\d\\d|\\d)", 85 j: "(\\d\\d|\\d)", 86 l: "", 87 m: "(\\d\\d|\\d)", 88 n: "(\\d\\d|\\d)", 89 s: "(\\d\\d|\\d)", 90 u: "(.+)", 91 w: "(\\d\\d|\\d)", 92 y: "(\\d{2})", 93}; 94export var formats = { 95 Z: function (date) { return date.toISOString(); }, 96 D: function (date, locale, options) { 97 return locale.weekdays.shorthand[formats.w(date, locale, options)]; 98 }, 99 F: function (date, locale, options) { 100 return monthToStr(formats.n(date, locale, options) - 1, false, locale); 101 }, 102 G: function (date, locale, options) { 103 return pad(formats.h(date, locale, options)); 104 }, 105 H: function (date) { return pad(date.getHours()); }, 106 J: function (date, locale) { 107 return locale.ordinal !== undefined 108 ? date.getDate() + locale.ordinal(date.getDate()) 109 : date.getDate(); 110 }, 111 K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; }, 112 M: function (date, locale) { 113 return monthToStr(date.getMonth(), true, locale); 114 }, 115 S: function (date) { return pad(date.getSeconds()); }, 116 U: function (date) { return date.getTime() / 1000; }, 117 W: function (date, _, options) { 118 return options.getWeek(date); 119 }, 120 Y: function (date) { return pad(date.getFullYear(), 4); }, 121 d: function (date) { return pad(date.getDate()); }, 122 h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); }, 123 i: function (date) { return pad(date.getMinutes()); }, 124 j: function (date) { return date.getDate(); }, 125 l: function (date, locale) { 126 return locale.weekdays.longhand[date.getDay()]; 127 }, 128 m: function (date) { return pad(date.getMonth() + 1); }, 129 n: function (date) { return date.getMonth() + 1; }, 130 s: function (date) { return date.getSeconds(); }, 131 u: function (date) { return date.getTime(); }, 132 w: function (date) { return date.getDay(); }, 133 y: function (date) { return String(date.getFullYear()).substring(2); }, 134};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.