PageSourceSearch

https://izumclub.ru/local/templates/izum/js/date.format.js?16406840185040

js izumclub.ru collected 2026-10-07 18:00:57 UTC 5,040 bytes, 94 lines download raw bytes

1/* eslint no-extend-native: 0 */
2
3(function () {
4  // Defining locale
5  Date.shortMonths = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
6  Date.longMonths = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
7  Date.shortDays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
8  Date.longDays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
9  // Defining patterns
10  var replaceChars = {
11    // Day
12    d: function () { var d = this.getDate(); return (d < 10 ? '0' : '') + d },
13    D: function () { return Date.shortDays[this.getDay()] },
14    j: function () { return this.getDate() },
15    l: function () { return Date.longDays[this.getDay()] },
16    N: function () { var N = this.getDay(); return (N === 0 ? 7 : N) },
17    S: function () { var S = this.getDate(); return (S % 10 === 1 && S !== 11 ? 'st' : (S % 10 === 2 && S !== 12 ? 'nd' : (S % 10 === 3 && S !== 13 ? 'rd' : 'th'))) },
18    w: function () { return this.getDay() },
19    z: function () { var d = new Date(this.getFullYear(), 0, 1); return Math.ceil((this - d) / 86400000) },
20    // Week
21    W: function () {
22      var target = new Date(this.valueOf())
23      var dayNr = (this.getDay() + 6) % 7
24      target.setDate(target.getDate() - dayNr + 3)
25      var firstThursday = target.valueOf()
26      target.setMonth(0, 1)
27      if (target.getDay() !== 4) {
28        target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7)
29      }
30      var retVal = 1 + Math.ceil((firstThursday - target) / 604800000)
31
32      return (retVal < 10 ? '0' + retVal : retVal)
33    },
34    // Month
35    F: function () { return Date.longMonths[this.getMonth()] },
36    m: function () { var m = this.getMonth(); return (m < 9 ? '0' : '') + (m + 1) },
37    M: function () { return Date.shortMonths[this.getMonth()] },
38    n: function () { return this.getMonth() + 1 },
39    t: function () {
40      var year = this.getFullYear()
41      var nextMonth = this.getMonth() + 1
42      if (nextMonth === 12) {
43        year = year++
44        nextMonth = 0
45      }
46      return new Date(year, nextMonth, 0).getDate()
47    },
48    // Year
49    L: function () { var L = this.getFullYear(); return (L % 400 === 0 || (L % 100 !== 0 && L % 4 === 0)) },
50    o: function () { var d = new Date(this.valueOf()); d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); return d.getFullYear() },
51    Y: function () { return this.getFullYear() },
52    y: function () { return ('' + this.getFullYear()).substr(2) },
53    // Time
54    a: function () { return this.getHours() < 12 ? 'am' : 'pm' },
55    A: function () { return this.getHours() < 12 ? 'AM' : 'PM' },
56    B: function () { return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTCMinutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24) },
57    g: function () { return this.getHours() % 12 || 12 },
58    G: function () { return this.getHours() },
59    h: function () { var h = this.getHours(); return ((h % 12 || 12) < 10 ? '0' : '') + (h % 12 || 12) },
60    H: function () { var H = this.getHours(); return (H < 10 ? '0' : '') + H },
61    i: function () { var i = this.getMinutes(); return (i < 10 ? '0' : '') + i },
62    s: function () { var s = this.getSeconds(); return (s < 10 ? '0' : '') + s },
63    v: function () { var v = this.getMilliseconds(); return (v < 10 ? '00' : (v < 100 ? '0' : '')) + v },
64    // Timezone
65    e: function () { return Intl.DateTimeFormat().resolvedOptions().timeZone },
66    I: function () {
67      var DST = null
68      for (var i = 0; i < 12; ++i) {
69        var d = new Date(this.getFullYear(), i, 1)
70        var offset = d.getTimezoneOffset()
71
72        if (DST === null) DST = offset
73        else if (offset < DST) { DST = offset; break } else if (offset > DST) break
74      }
75      return (this.getTimezoneOffset() === DST) | 0
76    },
77    O: function () { var O = this.getTimezoneOffset(); return (-O < 0 ? '-' : '+') + (Math.abs(O / 60) < 10 ? '0' : '') + Math.floor(Math.abs(O / 60)) + (Math.abs(O % 60) === 0 ? '00' : ((Math.abs(O % 60) < 10 ? '0' : '')) + (Math.abs(O % 60))) },
78    P: function () { var P = this.getTimezoneOffset(); return (-P < 0 ? '-' : '+') + (Math.abs(P / 60) < 10 ? '0' : '') + Math.floor(Math.abs(P / 60)) + ':' + (Math.abs(P % 60) === 0 ? '00' : ((Math.abs(P % 60) < 10 ? '0' : '')) + (Math.abs(P % 60))) },
79    T: function () { var tz = this.toLocaleTimeString(navigator.language, {timeZoneName: 'short'}).split(' '); return tz[tz.length - 1] },
80    Z: function () { return -this.getTimezoneOffset() * 60 },
81    // Full Date/Time
82    c: function () { return this.format('Y-m-d\\TH:i:sP') },
83    r: function () { return this.toString() },
84    U: function () { return Math.floor(this.getTime() / 1000) }
85  }
86
87  // Simulates PHP's date function
88  Date.prototype.format = function (format) {
89    var date = this
90    return format.replace(/(\\?)(.)/g, function (_, esc, chr) {
91      return (esc === '' && replaceChars[chr]) ? replaceChars[chr].call(date) : chr
92    })
93  }
94}).call(this)

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.