// warning: This file is auto generated by `yarn build:tests` // Do not edit by hand! import { createRequire } from 'node:module' import { describe, it, expect } from 'vitest' process.env.TZ = 'UTC' const ini_set = require('../../../../src/php/info/ini_set.ts').ini_set const ini_get = require('../../../../src/php/info/ini_get.ts').ini_get const __locutus_source_fn = require('../../../../src/php/datetime/date_parse.ts').date_parse const __locutus_source_module_url = new URL("../../../../src/php/datetime/date_parse.ts", import.meta.url) const __locutus_source_require = createRequire(__locutus_source_module_url) const __locutus_func_name = "date_parse" const __locutus_module_js_code = "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.date_parse = date_parse;\nconst strtotime_ts_1 = require(\"../datetime/strtotime.ts\");\nfunction date_parse(date) {\n // discuss at: https://locutus.io/php/date_parse/\n // original by: Brett Zamir (https://brett-zamir.me)\n // example 1: date_parse('2006-12-12 10:00:00')\n // returns 1: {year : 2006, month: 12, day: 12, hour: 10, minute: 0, second: 0, fraction: 0, is_localtime: false}\n let ts;\n try {\n ts = (0, strtotime_ts_1.strtotime)(date, undefined);\n }\n catch (_e) {\n ts = false;\n }\n if (!ts) {\n return false;\n }\n const dt = new Date(ts * 1000);\n const retObj = {\n year: dt.getFullYear(),\n month: dt.getMonth() + 1,\n day: dt.getDate(),\n hour: dt.getHours(),\n minute: dt.getMinutes(),\n second: dt.getSeconds(),\n fraction: Number.parseFloat(`0.${dt.getMilliseconds()}`),\n is_localtime: dt.getTimezoneOffset() !== 0,\n };\n return retObj;\n}" const __locutus_standalone_ts_code = "// php/datetime/strtotime (Locutus dependency module)\nconst reSpace = '[ \\\\t]+';\nconst reSpaceOpt = '[ \\\\t]*';\nconst reMeridian = '(?:([ap])\\\\.?m\\\\.?([\\\\t ]|$))';\nconst reHour24 = '(2[0-4]|[01]?[0-9])';\nconst reHour24lz = '([01][0-9]|2[0-4])';\nconst reHour12 = '(0?[1-9]|1[0-2])';\nconst reMinute = '([0-5]?[0-9])';\nconst reMinutelz = '([0-5][0-9])';\nconst reSecond = '(60|[0-5]?[0-9])';\nconst reSecondlz = '(60|[0-5][0-9])';\nconst reFrac = '(?:\\\\.([0-9]+))';\nconst reDayfull = 'sunday|monday|tuesday|wednesday|thursday|friday|saturday';\nconst reDayabbr = 'sun|mon|tue|wed|thu|fri|sat';\nconst reDaytext = reDayfull + '|' + reDayabbr + '|weekdays?';\nconst reReltextnumber = 'first|second|third|fourth|fifth|sixth|seventh|eighth?|ninth|tenth|eleventh|twelfth';\nconst reReltexttext = 'next|last|previous|this';\nconst reReltextunit = '(?:second|sec|minute|min|hour|day|fortnight|forthnight|month|year)s?|weeks|' + reDaytext;\nconst reYear = '([0-9]{1,4})';\nconst reYear2 = '([0-9]{2})';\nconst reYear4 = '([0-9]{4})';\nconst reYear4withSign = '([+-]?[0-9]{4})';\nconst reMonth = '(1[0-2]|0?[0-9])';\nconst reMonthlz = '(0[0-9]|1[0-2])';\nconst reDay = '(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)';\nconst reDaylz = '(0[0-9]|[1-2][0-9]|3[01])';\nconst reMonthFull = 'january|february|march|april|may|june|july|august|september|october|november|december';\nconst reMonthAbbr = 'jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec';\nconst reMonthroman = 'i[vx]|vi{0,3}|xi{0,2}|i{1,3}';\nconst reMonthText = '(' + reMonthFull + '|' + reMonthAbbr + '|' + reMonthroman + ')';\nconst reTzCorrection = '((?:GMT)?([+-])' + reHour24 + ':?' + reMinute + '?)';\nconst reTzAbbr = '\\\\(?([a-zA-Z]{1,6})\\\\)?';\nconst reDayOfYear = '(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])';\nconst reWeekOfYear = '(0[1-9]|[1-4][0-9]|5[0-3])';\nconst reDateNoYear = reMonthText + '[ .\\\\t-]*' + reDay + '[,.stndrh\\\\t ]*';\nfunction processMeridian(hour, meridian) {\n const normalizedMeridian = meridian?.toLowerCase();\n switch (normalizedMeridian) {\n case 'a':\n hour += hour === 12 ? -12 : 0;\n break;\n case 'p':\n hour += hour !== 12 ? 12 : 0;\n break;\n }\n return hour;\n}\nfunction processYear(yearStr) {\n let year = +yearStr;\n if (yearStr.length < 4 && year < 100) {\n year += year < 70 ? 2000 : 1900;\n }\n return year;\n}\nfunction lookupMonth(monthStr) {\n const monthLookup = {\n jan: 0,\n january: 0,\n i: 0,\n feb: 1,\n february: 1,\n ii: 1,\n mar: 2,\n march: 2,\n iii: 2,\n apr: 3,\n april: 3,\n iv: 3,\n may: 4,\n v: 4,\n jun: 5,\n june: 5,\n vi: 5,\n jul: 6,\n july: 6,\n vii: 6,\n aug: 7,\n august: 7,\n viii: 7,\n sep: 8,\n sept: 8,\n september: 8,\n ix: 8,\n oct: 9,\n october: 9,\n x: 9,\n nov: 10,\n november: 10,\n xi: 10,\n dec: 11,\n december: 11,\n xii: 11,\n };\n return monthLookup[monthStr.toLowerCase()] ?? Number.NaN;\n}\nfunction lookupWeekday(dayStr, desiredSundayNumber = 0) {\n const dayNumbers = {\n mon: 1,\n monday: 1,\n tue: 2,\n tuesday: 2,\n wed: 3,\n wednesday: 3,\n thu: 4,\n thursday: 4,\n fri: 5,\n friday: 5,\n sat: 6,\n saturday: 6,\n sun: 0,\n sunday: 0,\n };\n return dayNumbers[dayStr.toLowerCase()] || desiredSundayNumber;\n}\nfunction lookupRelative(relText) {\n const relativeNumbers = {\n last: -1,\n previous: -1,\n this: 0,\n first: 1,\n next: 1,\n second: 2,\n third: 3,\n fourth: 4,\n fifth: 5,\n sixth: 6,\n seventh: 7,\n eight: 8,\n eighth: 8,\n ninth: 9,\n tenth: 10,\n eleventh: 11,\n twelfth: 12,\n };\n const relativeBehavior = {\n this: 1,\n };\n const relTextLower = relText.toLowerCase();\n return {\n amount: relativeNumbers[relTextLower] ?? 0,\n behavior: relativeBehavior[relTextLower] || 0,\n };\n}\nfunction processTzCorrection(tzOffset, oldValue = Number.NaN) {\n const reTzCorrectionLoose = /(?:GMT)?([+-])(\\d+)(:?)(\\d{0,2})/i;\n const tzMatch = tzOffset?.match(reTzCorrectionLoose);\n if (!tzMatch) {\n return oldValue;\n }\n const sign = tzMatch[1] === '-' ? -1 : 1;\n let hours = +(tzMatch[2] ?? 0);\n let minutes = +(tzMatch[4] ?? 0);\n if (!tzMatch[4] && !tzMatch[3]) {\n minutes = Math.floor(hours % 100);\n hours = Math.floor(hours / 100);\n }\n // timezone offset in seconds\n return sign * (hours * 60 + minutes) * 60;\n}\n// tz abbrevation : tz offset in seconds\nconst tzAbbrOffsets = {\n acdt: 37800,\n acst: 34200,\n addt: -7200,\n adt: -10800,\n aedt: 39600,\n aest: 36000,\n ahdt: -32400,\n ahst: -36000,\n akdt: -28800,\n akst: -32400,\n amt: -13840,\n apt: -10800,\n ast: -14400,\n awdt: 32400,\n awst: 28800,\n awt: -10800,\n bdst: 7200,\n bdt: -36000,\n bmt: -14309,\n bst: 3600,\n cast: 34200,\n cat: 7200,\n cddt: -14400,\n cdt: -18000,\n cemt: 10800,\n cest: 7200,\n cet: 3600,\n cmt: -15408,\n cpt: -18000,\n cst: -21600,\n cwt: -18000,\n chst: 36000,\n dmt: -1521,\n eat: 10800,\n eddt: -10800,\n edt: -14400,\n eest: 10800,\n eet: 7200,\n emt: -26248,\n ept: -14400,\n est: -18000,\n ewt: -14400,\n ffmt: -14660,\n fmt: -4056,\n gdt: 39600,\n gmt: 0,\n gst: 36000,\n hdt: -34200,\n hkst: 32400,\n hkt: 28800,\n hmt: -19776,\n hpt: -34200,\n hst: -36000,\n hwt: -34200,\n iddt: 14400,\n idt: 10800,\n imt: 25025,\n ist: 7200,\n jdt: 36000,\n jmt: 8440,\n jst: 32400,\n kdt: 36000,\n kmt: 5736,\n kst: 30600,\n lst: 9394,\n mddt: -18000,\n mdst: 16279,\n mdt: -21600,\n mest: 7200,\n met: 3600,\n mmt: 9017,\n mpt: -21600,\n msd: 14400,\n msk: 10800,\n mst: -25200,\n mwt: -21600,\n nddt: -5400,\n ndt: -9052,\n npt: -9000,\n nst: -12600,\n nwt: -9000,\n nzdt: 46800,\n nzmt: 41400,\n nzst: 43200,\n pddt: -21600,\n pdt: -25200,\n pkst: 21600,\n pkt: 18000,\n plmt: 25590,\n pmt: -13236,\n ppmt: -17340,\n ppt: -25200,\n pst: -28800,\n pwt: -25200,\n qmt: -18840,\n rmt: 5794,\n sast: 7200,\n sdmt: -16800,\n sjmt: -20173,\n smt: -13884,\n sst: -39600,\n tbmt: 10751,\n tmt: 12344,\n uct: 0,\n utc: 0,\n wast: 7200,\n wat: 3600,\n wemt: 7200,\n west: 3600,\n wet: 0,\n wib: 25200,\n wita: 28800,\n wit: 32400,\n wmt: 5040,\n yddt: -25200,\n ydt: -28800,\n ypt: -28800,\n yst: -32400,\n ywt: -28800,\n a: 3600,\n b: 7200,\n c: 10800,\n d: 14400,\n e: 18000,\n f: 21600,\n g: 25200,\n h: 28800,\n i: 32400,\n k: 36000,\n l: 39600,\n m: 43200,\n n: -3600,\n o: -7200,\n p: -10800,\n q: -14400,\n r: -18000,\n s: -21600,\n t: -25200,\n u: -28800,\n v: -32400,\n w: -36000,\n x: -39600,\n y: -43200,\n z: 0,\n};\nconst formats = {\n yesterday: {\n regex: /^yesterday/i,\n name: 'yesterday',\n callback() {\n this.rd -= 1;\n return this.resetTime();\n },\n },\n now: {\n regex: /^now/i,\n name: 'now',\n // do nothing\n },\n noon: {\n regex: /^noon/i,\n name: 'noon',\n callback() {\n return this.resetTime() && this.time(12, 0, 0, 0);\n },\n },\n midnightOrToday: {\n regex: /^(midnight|today)/i,\n name: 'midnight | today',\n callback() {\n return this.resetTime();\n },\n },\n tomorrow: {\n regex: /^tomorrow/i,\n name: 'tomorrow',\n callback() {\n this.rd += 1;\n return this.resetTime();\n },\n },\n timestamp: {\n regex: /^@(-?\\d+)/i,\n name: 'timestamp',\n callback(match, timestamp) {\n this.rs += +timestamp;\n this.y = 1970;\n this.m = 0;\n this.d = 1;\n this.dates = 0;\n return this.resetTime() && this.zone(0);\n },\n },\n firstOrLastDay: {\n regex: /^(first|last) day of/i,\n name: 'firstdayof | lastdayof',\n callback(match, day) {\n if (day.toLowerCase() === 'first') {\n this.firstOrLastDayOfMonth = 1;\n }\n else {\n this.firstOrLastDayOfMonth = -1;\n }\n },\n },\n backOrFrontOf: {\n regex: new RegExp('^(back|front) of ' + reHour24 + reSpaceOpt + reMeridian + '?', 'i'),\n name: 'backof | frontof',\n callback(match, side, hours, meridian) {\n const back = side.toLowerCase() === 'back';\n let hour = +hours;\n let minute = 15;\n if (!back) {\n hour -= 1;\n minute = 45;\n }\n hour = processMeridian(hour, meridian);\n return this.resetTime() && this.time(hour, minute, 0, 0);\n },\n },\n weekdayOf: {\n regex: new RegExp('^(' +\n reReltextnumber +\n '|' +\n reReltexttext +\n ')' +\n reSpace +\n '(' +\n reDayfull +\n '|' +\n reDayabbr +\n ')' +\n reSpace +\n 'of', 'i'),\n name: 'weekdayof',\n // todo\n },\n mssqltime: {\n regex: new RegExp('^' + reHour12 + ':' + reMinutelz + ':' + reSecondlz + '[:.]([0-9]+)' + reMeridian, 'i'),\n name: 'mssqltime',\n callback(match, hour, minute, second, frac, meridian) {\n return this.time(processMeridian(+hour, meridian), +minute, +second, +frac.substr(0, 3));\n },\n },\n oracledate: {\n regex: /^(\\d{2})-([A-Z]{3})-(\\d{2})$/i,\n name: 'd-M-y',\n callback(match, day, monthText, year) {\n const monthByName = {\n JAN: 0,\n FEB: 1,\n MAR: 2,\n APR: 3,\n MAY: 4,\n JUN: 5,\n JUL: 6,\n AUG: 7,\n SEP: 8,\n OCT: 9,\n NOV: 10,\n DEC: 11,\n };\n const month = monthByName[monthText.toUpperCase()] ?? Number.NaN;\n return this.ymd(2000 + parseInt(year, 10), month, parseInt(day, 10));\n },\n },\n timeLong12: {\n regex: new RegExp('^' + reHour12 + '[:.]' + reMinute + '[:.]' + reSecondlz + reSpaceOpt + reMeridian, 'i'),\n name: 'timelong12',\n callback(match, hour, minute, second, meridian) {\n return this.time(processMeridian(+hour, meridian), +minute, +second, 0);\n },\n },\n timeShort12: {\n regex: new RegExp('^' + reHour12 + '[:.]' + reMinutelz + reSpaceOpt + reMeridian, 'i'),\n name: 'timeshort12',\n callback(match, hour, minute, meridian) {\n return this.time(processMeridian(+hour, meridian), +minute, 0, 0);\n },\n },\n timeTiny12: {\n regex: new RegExp('^' + reHour12 + reSpaceOpt + reMeridian, 'i'),\n name: 'timetiny12',\n callback(match, hour, meridian) {\n return this.time(processMeridian(+hour, meridian), 0, 0, 0);\n },\n },\n soap: {\n regex: new RegExp('^' +\n reYear4 +\n '-' +\n reMonthlz +\n '-' +\n reDaylz +\n 'T' +\n reHour24lz +\n ':' +\n reMinutelz +\n ':' +\n reSecondlz +\n reFrac +\n reTzCorrection +\n '?', 'i'),\n name: 'soap',\n callback(match, year, month, day, hour, minute, second, frac, tzCorrection) {\n return (this.ymd(+year, +month - 1, +day) &&\n this.time(+hour, +minute, +second, +frac.substr(0, 3)) &&\n this.zone(processTzCorrection(tzCorrection)));\n },\n },\n wddx: {\n regex: new RegExp('^' + reYear4 + '-' + reMonth + '-' + reDay + 'T' + reHour24 + ':' + reMinute + ':' + reSecond),\n name: 'wddx',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n exif: {\n regex: new RegExp('^' + reYear4 + ':' + reMonthlz + ':' + reDaylz + ' ' + reHour24lz + ':' + reMinutelz + ':' + reSecondlz, 'i'),\n name: 'exif',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n xmlRpc: {\n regex: new RegExp('^' + reYear4 + reMonthlz + reDaylz + 'T' + reHour24 + ':' + reMinutelz + ':' + reSecondlz),\n name: 'xmlrpc',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n xmlRpcNoColon: {\n regex: new RegExp('^' + reYear4 + reMonthlz + reDaylz + '[Tt]' + reHour24 + reMinutelz + reSecondlz),\n name: 'xmlrpcnocolon',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n clf: {\n regex: new RegExp('^' +\n reDay +\n '/(' +\n reMonthAbbr +\n ')/' +\n reYear4 +\n ':' +\n reHour24lz +\n ':' +\n reMinutelz +\n ':' +\n reSecondlz +\n reSpace +\n reTzCorrection, 'i'),\n name: 'clf',\n callback(match, day, month, year, hour, minute, second, tzCorrection) {\n return (this.ymd(+year, lookupMonth(month), +day) &&\n this.time(+hour, +minute, +second, 0) &&\n this.zone(processTzCorrection(tzCorrection)));\n },\n },\n iso8601long: {\n regex: new RegExp('^t?' + reHour24 + '[:.]' + reMinute + '[:.]' + reSecond + reFrac, 'i'),\n name: 'iso8601long',\n callback(match, hour, minute, second, frac) {\n return this.time(+hour, +minute, +second, +frac.substr(0, 3));\n },\n },\n dateTextual: {\n regex: new RegExp('^' + reMonthText + '[ .\\\\t-]*' + reDay + '[,.stndrh\\\\t ]+' + reYear, 'i'),\n name: 'datetextual',\n callback(match, month, day, year) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n pointedDate4: {\n regex: new RegExp('^' + reDay + '[.\\\\t-]' + reMonth + '[.-]' + reYear4),\n name: 'pointeddate4',\n callback(match, day, month, year) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n pointedDate2: {\n regex: new RegExp('^' + reDay + '[.\\\\t]' + reMonth + '\\\\.' + reYear2),\n name: 'pointeddate2',\n callback(match, day, month, year) {\n return this.ymd(processYear(year), +month - 1, +day);\n },\n },\n timeLong24: {\n regex: new RegExp('^t?' + reHour24 + '[:.]' + reMinute + '[:.]' + reSecond),\n name: 'timelong24',\n callback(match, hour, minute, second) {\n return this.time(+hour, +minute, +second, 0);\n },\n },\n dateNoColon: {\n regex: new RegExp('^' + reYear4 + reMonthlz + reDaylz),\n name: 'datenocolon',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n pgydotd: {\n regex: new RegExp('^' + reYear4 + '\\\\.?' + reDayOfYear),\n name: 'pgydotd',\n callback(match, year, day) {\n return this.ymd(+year, 0, +day);\n },\n },\n timeShort24: {\n regex: new RegExp('^t?' + reHour24 + '[:.]' + reMinute, 'i'),\n name: 'timeshort24',\n callback(match, hour, minute) {\n return this.time(+hour, +minute, 0, 0);\n },\n },\n iso8601noColon: {\n regex: new RegExp('^t?' + reHour24lz + reMinutelz + reSecondlz, 'i'),\n name: 'iso8601nocolon',\n callback(match, hour, minute, second) {\n return this.time(+hour, +minute, +second, 0);\n },\n },\n iso8601dateSlash: {\n // eventhough the trailing slash is optional in PHP\n // here it's mandatory and inputs without the slash\n // are handled by dateslash\n regex: new RegExp('^' + reYear4 + '/' + reMonthlz + '/' + reDaylz + '/'),\n name: 'iso8601dateslash',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n dateSlash: {\n regex: new RegExp('^' + reYear4 + '/' + reMonth + '/' + reDay),\n name: 'dateslash',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n american: {\n regex: new RegExp('^' + reMonth + '/' + reDay + '/' + reYear),\n name: 'american',\n callback(match, month, day, year) {\n return this.ymd(processYear(year), +month - 1, +day);\n },\n },\n americanShort: {\n regex: new RegExp('^' + reMonth + '/' + reDay),\n name: 'americanshort',\n callback(match, month, day) {\n return this.ymd(this.y, +month - 1, +day);\n },\n },\n gnuDateShortOrIso8601date2: {\n // iso8601date2 is complete subset of gnudateshort\n regex: new RegExp('^' + reYear + '-' + reMonth + '-' + reDay),\n name: 'gnudateshort | iso8601date2',\n callback(match, year, month, day) {\n return this.ymd(processYear(year), +month - 1, +day);\n },\n },\n iso8601date4: {\n regex: new RegExp('^' + reYear4withSign + '-' + reMonthlz + '-' + reDaylz),\n name: 'iso8601date4',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n gnuNoColon: {\n regex: new RegExp('^t?' + reHour24lz + reMinutelz, 'i'),\n name: 'gnunocolon',\n callback(match, hour, minute) {\n // this rule is a special case\n // if time was already set once by any preceding rule, it sets the captured value as year\n switch (this.times) {\n case 0:\n return this.time(+hour, +minute, 0, this.f);\n case 1:\n this.y = +hour * 100 + +minute;\n this.times++;\n return true;\n default:\n return false;\n }\n },\n },\n gnuDateShorter: {\n regex: new RegExp('^' + reYear4 + '-' + reMonth),\n name: 'gnudateshorter',\n callback(match, year, month) {\n return this.ymd(+year, +month - 1, 1);\n },\n },\n pgTextReverse: {\n // note: allowed years are from 32-9999\n // years below 32 should be treated as days in datefull\n regex: new RegExp('^' + '(\\\\d{3,4}|[4-9]\\\\d|3[2-9])-(' + reMonthAbbr + ')-' + reDaylz, 'i'),\n name: 'pgtextreverse',\n callback(match, year, month, day) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n dateFull: {\n regex: new RegExp('^' + reDay + '[ \\\\t.-]*' + reMonthText + '[ \\\\t.-]*' + reYear, 'i'),\n name: 'datefull',\n callback(match, day, month, year) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n dateNoDay: {\n regex: new RegExp('^' + reMonthText + '[ .\\\\t-]*' + reYear4, 'i'),\n name: 'datenoday',\n callback(match, month, year) {\n return this.ymd(+year, lookupMonth(month), 1);\n },\n },\n dateNoDayRev: {\n regex: new RegExp('^' + reYear4 + '[ .\\\\t-]*' + reMonthText, 'i'),\n name: 'datenodayrev',\n callback(match, year, month) {\n return this.ymd(+year, lookupMonth(month), 1);\n },\n },\n pgTextShort: {\n regex: new RegExp('^(' + reMonthAbbr + ')-' + reDaylz + '-' + reYear, 'i'),\n name: 'pgtextshort',\n callback(match, month, day, year) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n dateNoYear: {\n regex: new RegExp('^' + reDateNoYear, 'i'),\n name: 'datenoyear',\n callback(match, month, day) {\n return this.ymd(this.y, lookupMonth(month), +day);\n },\n },\n dateNoYearRev: {\n regex: new RegExp('^' + reDay + '[ .\\\\t-]*' + reMonthText, 'i'),\n name: 'datenoyearrev',\n callback(match, day, month) {\n return this.ymd(this.y, lookupMonth(month), +day);\n },\n },\n isoWeekDay: {\n regex: new RegExp('^' + reYear4 + '-?W' + reWeekOfYear + '(?:-?([0-7]))?'),\n name: 'isoweekday | isoweek',\n callback(match, year, week, day) {\n const dayOfWeek = day ? +day : 1;\n if (!this.ymd(+year, 0, 1)) {\n return false;\n }\n // get day of week for Jan 1st\n let jan1DayOfWeek = new Date(this.y, this.m, this.d).getDay();\n // and use the day to figure out the offset for day 1 of week 1\n jan1DayOfWeek = 0 - (jan1DayOfWeek > 4 ? jan1DayOfWeek - 7 : jan1DayOfWeek);\n this.rd += jan1DayOfWeek + (+week - 1) * 7 + dayOfWeek;\n return true;\n },\n },\n relativeText: {\n regex: new RegExp('^(' + reReltextnumber + '|' + reReltexttext + ')' + reSpace + '(' + reReltextunit + ')', 'i'),\n name: 'relativetext',\n callback(match, relValue, relUnit) {\n // todo: implement handling of 'this time-unit'\n // biome-ignore lint/correctness/noUnusedVariables: behavior reserved for future use\n const { amount, behavior } = lookupRelative(relValue);\n switch (relUnit.toLowerCase()) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n this.rs += amount;\n break;\n case 'min':\n case 'mins':\n case 'minute':\n case 'minutes':\n this.ri += amount;\n break;\n case 'hour':\n case 'hours':\n this.rh += amount;\n break;\n case 'day':\n case 'days':\n this.rd += amount;\n break;\n case 'fortnight':\n case 'fortnights':\n case 'forthnight':\n case 'forthnights':\n this.rd += amount * 14;\n break;\n case 'week':\n case 'weeks':\n this.rd += amount * 7;\n break;\n case 'month':\n case 'months':\n this.rm += amount;\n break;\n case 'year':\n case 'years':\n this.ry += amount;\n break;\n case 'mon':\n case 'monday':\n case 'tue':\n case 'tuesday':\n case 'wed':\n case 'wednesday':\n case 'thu':\n case 'thursday':\n case 'fri':\n case 'friday':\n case 'sat':\n case 'saturday':\n case 'sun':\n case 'sunday':\n this.resetTime();\n this.weekday = lookupWeekday(relUnit, 7);\n this.weekdayBehavior = 1;\n this.rd += (amount > 0 ? amount - 1 : amount) * 7;\n break;\n case 'weekday':\n case 'weekdays':\n // todo\n break;\n }\n },\n },\n relative: {\n regex: new RegExp('^([+-]*)[ \\\\t]*(\\\\d+)' + reSpaceOpt + '(' + reReltextunit + '|week)', 'i'),\n name: 'relative',\n callback(match, signs, relValue, relUnit) {\n const minuses = signs.replace(/[^-]/g, '').length;\n const amount = +relValue * Math.pow(-1, minuses);\n switch (relUnit.toLowerCase()) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n this.rs += amount;\n break;\n case 'min':\n case 'mins':\n case 'minute':\n case 'minutes':\n this.ri += amount;\n break;\n case 'hour':\n case 'hours':\n this.rh += amount;\n break;\n case 'day':\n case 'days':\n this.rd += amount;\n break;\n case 'fortnight':\n case 'fortnights':\n case 'forthnight':\n case 'forthnights':\n this.rd += amount * 14;\n break;\n case 'week':\n case 'weeks':\n this.rd += amount * 7;\n break;\n case 'month':\n case 'months':\n this.rm += amount;\n break;\n case 'year':\n case 'years':\n this.ry += amount;\n break;\n case 'mon':\n case 'monday':\n case 'tue':\n case 'tuesday':\n case 'wed':\n case 'wednesday':\n case 'thu':\n case 'thursday':\n case 'fri':\n case 'friday':\n case 'sat':\n case 'saturday':\n case 'sun':\n case 'sunday':\n this.resetTime();\n this.weekday = lookupWeekday(relUnit, 7);\n this.weekdayBehavior = 1;\n this.rd += (amount > 0 ? amount - 1 : amount) * 7;\n break;\n case 'weekday':\n case 'weekdays':\n // todo\n break;\n }\n },\n },\n dayText: {\n regex: new RegExp('^(' + reDaytext + ')', 'i'),\n name: 'daytext',\n callback(match, dayText) {\n this.resetTime();\n this.weekday = lookupWeekday(dayText, 0);\n if (this.weekdayBehavior !== 2) {\n this.weekdayBehavior = 1;\n }\n },\n },\n relativeTextWeek: {\n regex: new RegExp('^(' + reReltexttext + ')' + reSpace + 'week', 'i'),\n name: 'relativetextweek',\n callback(match, relText) {\n this.weekdayBehavior = 2;\n switch (relText.toLowerCase()) {\n case 'this':\n this.rd += 0;\n break;\n case 'next':\n this.rd += 7;\n break;\n case 'last':\n case 'previous':\n this.rd -= 7;\n break;\n }\n if (isNaN(this.weekday)) {\n this.weekday = 1;\n }\n },\n },\n monthFullOrMonthAbbr: {\n regex: new RegExp('^(' + reMonthFull + '|' + reMonthAbbr + ')', 'i'),\n name: 'monthfull | monthabbr',\n callback(match, month) {\n return this.ymd(this.y, lookupMonth(month), this.d);\n },\n },\n tzCorrection: {\n regex: new RegExp('^' + reTzCorrection, 'i'),\n name: 'tzcorrection',\n callback(tzCorrection) {\n return this.zone(processTzCorrection(tzCorrection));\n },\n },\n tzAbbr: {\n regex: new RegExp('^' + reTzAbbr),\n name: 'tzabbr',\n callback(match, abbr) {\n const offset = tzAbbrOffsets[abbr.toLowerCase()];\n if (offset == null || Number.isNaN(offset)) {\n return false;\n }\n return this.zone(offset);\n },\n },\n ago: {\n regex: /^ago/i,\n name: 'ago',\n callback() {\n this.ry = -this.ry;\n this.rm = -this.rm;\n this.rd = -this.rd;\n this.rh = -this.rh;\n this.ri = -this.ri;\n this.rs = -this.rs;\n this.rf = -this.rf;\n },\n },\n year4: {\n regex: new RegExp('^' + reYear4),\n name: 'year4',\n callback(match, year) {\n this.y = +year;\n return true;\n },\n },\n whitespace: {\n regex: /^[ .,\\t]+/,\n name: 'whitespace',\n // do nothing\n },\n dateShortWithTimeLong: {\n regex: new RegExp('^' + reDateNoYear + 't?' + reHour24 + '[:.]' + reMinute + '[:.]' + reSecond, 'i'),\n name: 'dateshortwithtimelong',\n callback(match, month, day, hour, minute, second) {\n return this.ymd(this.y, lookupMonth(month), +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n dateShortWithTimeLong12: {\n regex: new RegExp('^' + reDateNoYear + reHour12 + '[:.]' + reMinute + '[:.]' + reSecondlz + reSpaceOpt + reMeridian, 'i'),\n name: 'dateshortwithtimelong12',\n callback(match, month, day, hour, minute, second, meridian) {\n return (this.ymd(this.y, lookupMonth(month), +day) && this.time(processMeridian(+hour, meridian), +minute, +second, 0));\n },\n },\n dateShortWithTimeShort: {\n regex: new RegExp('^' + reDateNoYear + 't?' + reHour24 + '[:.]' + reMinute, 'i'),\n name: 'dateshortwithtimeshort',\n callback(match, month, day, hour, minute) {\n return this.ymd(this.y, lookupMonth(month), +day) && this.time(+hour, +minute, 0, 0);\n },\n },\n dateShortWithTimeShort12: {\n regex: new RegExp('^' + reDateNoYear + reHour12 + '[:.]' + reMinutelz + reSpaceOpt + reMeridian, 'i'),\n name: 'dateshortwithtimeshort12',\n callback(match, month, day, hour, minute, meridian) {\n return this.ymd(this.y, lookupMonth(month), +day) && this.time(processMeridian(+hour, meridian), +minute, 0, 0);\n },\n },\n};\nconst resultProto = {\n // date\n y: NaN,\n m: NaN,\n d: NaN,\n // time\n h: NaN,\n i: NaN,\n s: NaN,\n f: NaN,\n // relative shifts\n ry: 0,\n rm: 0,\n rd: 0,\n rh: 0,\n ri: 0,\n rs: 0,\n rf: 0,\n // weekday related shifts\n weekday: NaN,\n weekdayBehavior: 0,\n // first or last day of month\n // 0 none, 1 first, -1 last\n firstOrLastDayOfMonth: 0,\n // timezone correction in minutes\n z: NaN,\n // counters\n dates: 0,\n times: 0,\n zones: 0,\n // helper functions\n ymd(y, m, d) {\n if (this.dates > 0) {\n return false;\n }\n this.dates++;\n this.y = y;\n this.m = m;\n this.d = d;\n return true;\n },\n time(h, i, s, f) {\n if (this.times > 0) {\n return false;\n }\n this.times++;\n this.h = h;\n this.i = i;\n this.s = s;\n this.f = f;\n return true;\n },\n resetTime() {\n this.h = 0;\n this.i = 0;\n this.s = 0;\n this.f = 0;\n this.times = 0;\n return true;\n },\n zone(minutes) {\n if (this.zones <= 1) {\n this.zones++;\n this.z = minutes;\n return true;\n }\n return false;\n },\n toDate(relativeTo) {\n if (this.dates && !this.times) {\n this.h = this.i = this.s = this.f = 0;\n }\n // fill holes\n if (isNaN(this.y)) {\n this.y = relativeTo.getFullYear();\n }\n if (isNaN(this.m)) {\n this.m = relativeTo.getMonth();\n }\n if (isNaN(this.d)) {\n this.d = relativeTo.getDate();\n }\n if (isNaN(this.h)) {\n this.h = relativeTo.getHours();\n }\n if (isNaN(this.i)) {\n this.i = relativeTo.getMinutes();\n }\n if (isNaN(this.s)) {\n this.s = relativeTo.getSeconds();\n }\n if (isNaN(this.f)) {\n this.f = relativeTo.getMilliseconds();\n }\n // adjust special early\n switch (this.firstOrLastDayOfMonth) {\n case 1:\n this.d = 1;\n break;\n case -1:\n this.d = 0;\n this.m += 1;\n break;\n }\n if (!isNaN(this.weekday)) {\n const date = new Date(relativeTo.getTime());\n date.setFullYear(this.y, this.m, this.d);\n date.setHours(this.h, this.i, this.s, this.f);\n const dow = date.getDay();\n if (this.weekdayBehavior === 2) {\n // To make \"this week\" work, where the current day of week is a \"sunday\"\n if (dow === 0 && this.weekday !== 0) {\n this.weekday = -6;\n }\n // To make \"sunday this week\" work, where the current day of week is not a \"sunday\"\n if (this.weekday === 0 && dow !== 0) {\n this.weekday = 7;\n }\n this.d -= dow;\n this.d += this.weekday;\n }\n else {\n let diff = this.weekday - dow;\n // some PHP magic\n if ((this.rd < 0 && diff < 0) || (this.rd >= 0 && diff <= -this.weekdayBehavior)) {\n diff += 7;\n }\n if (this.weekday >= 0) {\n this.d += diff;\n }\n else {\n this.d -= 7 - (Math.abs(this.weekday) - dow);\n }\n this.weekday = NaN;\n }\n }\n // adjust relative\n this.y += this.ry;\n this.m += this.rm;\n this.d += this.rd;\n this.h += this.rh;\n this.i += this.ri;\n this.s += this.rs;\n this.f += this.rf;\n this.ry = this.rm = this.rd = 0;\n this.rh = this.ri = this.rs = this.rf = 0;\n const result = new Date(relativeTo.getTime());\n // since Date constructor treats years <= 99 as 1900+\n // it can't be used, thus this weird way\n result.setFullYear(this.y, this.m, this.d);\n result.setHours(this.h, this.i, this.s, this.f);\n // note: this is done twice in PHP\n // early when processing special relatives\n // and late\n // todo: check if the logic can be reduced\n // to just one time action\n switch (this.firstOrLastDayOfMonth) {\n case 1:\n result.setDate(1);\n break;\n case -1:\n result.setMonth(result.getMonth() + 1, 0);\n break;\n }\n // adjust timezone\n if (!isNaN(this.z) && result.getTimezoneOffset() !== this.z) {\n result.setUTCFullYear(result.getFullYear(), result.getMonth(), result.getDate());\n result.setUTCHours(result.getHours(), result.getMinutes(), result.getSeconds() - this.z, result.getMilliseconds());\n }\n return result;\n },\n};\nfunction strtotime(str, now) {\n // discuss at: https://locutus.io/php/strtotime/\n // original by: Caio Ariede (https://caioariede.com)\n // improved by: Kevin van Zonneveld (https://kvz.io)\n // improved by: Caio Ariede (https://caioariede.com)\n // improved by: A. Matías Quezada (https://amatiasq.com)\n // improved by: preuter\n // improved by: Brett Zamir (https://brett-zamir.me)\n // improved by: Mirko Faber\n // input by: David\n // bugfixed by: Wagner B. Soares\n // bugfixed by: Artur Tchernychev\n // bugfixed by: Stephan Bösch-Plepelits (https://github.com/plepe)\n // reimplemented by: Rafał Kukawski\n // note 1: Examples all have a fixed timestamp to prevent\n // note 1: tests to fail because of variable time(zones)\n // example 1: strtotime('+1 day', 1129633200)\n // returns 1: 1129719600\n // example 2: strtotime('+1 week 2 days 4 hours 2 seconds', 1129633200)\n // returns 2: 1130425202\n // example 3: strtotime('last month', 1129633200)\n // returns 3: 1127041200\n // example 4: strtotime('2009-05-04 08:30:00+00')\n // returns 4: 1241425800\n // example 5: strtotime('2009-05-04 08:30:00+02:00')\n // returns 5: 1241418600\n // example 6: strtotime('2009-05-04 08:30:00 YWT')\n // returns 6: 1241454600\n // example 7: strtotime('10-JUL-17')\n // returns 7: 1499644800\n const nowSeconds = now == null ? Math.floor(Date.now() / 1000) : now;\n str = String(str);\n // the rule order is important\n // if multiple rules match, the longest match wins\n // if multiple rules match the same string, the first match wins\n const rules = [\n formats.yesterday,\n formats.now,\n formats.noon,\n formats.midnightOrToday,\n formats.tomorrow,\n formats.timestamp,\n formats.firstOrLastDay,\n formats.backOrFrontOf,\n // formats.weekdayOf, // not yet implemented\n formats.timeTiny12,\n formats.timeShort12,\n formats.timeLong12,\n formats.mssqltime,\n formats.oracledate,\n formats.timeShort24,\n formats.timeLong24,\n formats.iso8601long,\n formats.gnuNoColon,\n formats.iso8601noColon,\n formats.americanShort,\n formats.american,\n formats.iso8601date4,\n formats.iso8601dateSlash,\n formats.dateSlash,\n formats.gnuDateShortOrIso8601date2,\n formats.gnuDateShorter,\n formats.dateFull,\n formats.pointedDate4,\n formats.pointedDate2,\n formats.dateNoDay,\n formats.dateNoDayRev,\n formats.dateTextual,\n formats.dateNoYear,\n formats.dateNoYearRev,\n formats.dateNoColon,\n formats.xmlRpc,\n formats.xmlRpcNoColon,\n formats.soap,\n formats.wddx,\n formats.exif,\n formats.pgydotd,\n formats.isoWeekDay,\n formats.pgTextShort,\n formats.pgTextReverse,\n formats.clf,\n formats.year4,\n formats.ago,\n formats.dayText,\n formats.relativeTextWeek,\n formats.relativeText,\n formats.monthFullOrMonthAbbr,\n formats.tzCorrection,\n formats.tzAbbr,\n formats.dateShortWithTimeShort12,\n formats.dateShortWithTimeLong12,\n formats.dateShortWithTimeShort,\n formats.dateShortWithTimeLong,\n formats.relative,\n formats.whitespace,\n ];\n const result = { ...resultProto };\n while (str.length) {\n let longestMatch = null;\n let finalRule = null;\n for (const format of rules) {\n const match = str.match(format.regex);\n if (match) {\n if (!longestMatch || match[0].length > longestMatch[0].length) {\n longestMatch = match;\n finalRule = format;\n }\n }\n }\n if (!finalRule || !longestMatch) {\n return false;\n }\n if (finalRule.callback && finalRule.callback.apply(result, longestMatch) === false) {\n return false;\n }\n str = str.substr(longestMatch[0].length);\n finalRule = null;\n longestMatch = null;\n }\n return Math.floor(result.toDate(new Date(nowSeconds * 1000)).getTime() / 1000);\n}\nfunction date_parse(date) {\n // discuss at: https://locutus.io/php/date_parse/\n // original by: Brett Zamir (https://brett-zamir.me)\n // example 1: date_parse('2006-12-12 10:00:00')\n // returns 1: {year : 2006, month: 12, day: 12, hour: 10, minute: 0, second: 0, fraction: 0, is_localtime: false}\n let ts;\n try {\n ts = strtotime(date, undefined);\n }\n catch (_e) {\n ts = false;\n }\n if (!ts) {\n return false;\n }\n const dt = new Date(ts * 1000);\n const retObj = {\n year: dt.getFullYear(),\n month: dt.getMonth() + 1,\n day: dt.getDate(),\n hour: dt.getHours(),\n minute: dt.getMinutes(),\n second: dt.getSeconds(),\n fraction: Number.parseFloat(`0.${dt.getMilliseconds()}`),\n is_localtime: dt.getTimezoneOffset() !== 0,\n };\n return retObj;\n}" const __locutus_standalone_js_code = "// php/datetime/strtotime (Locutus dependency module)\nconst reSpace = '[ \\\\t]+';\nconst reSpaceOpt = '[ \\\\t]*';\nconst reMeridian = '(?:([ap])\\\\.?m\\\\.?([\\\\t ]|$))';\nconst reHour24 = '(2[0-4]|[01]?[0-9])';\nconst reHour24lz = '([01][0-9]|2[0-4])';\nconst reHour12 = '(0?[1-9]|1[0-2])';\nconst reMinute = '([0-5]?[0-9])';\nconst reMinutelz = '([0-5][0-9])';\nconst reSecond = '(60|[0-5]?[0-9])';\nconst reSecondlz = '(60|[0-5][0-9])';\nconst reFrac = '(?:\\\\.([0-9]+))';\nconst reDayfull = 'sunday|monday|tuesday|wednesday|thursday|friday|saturday';\nconst reDayabbr = 'sun|mon|tue|wed|thu|fri|sat';\nconst reDaytext = reDayfull + '|' + reDayabbr + '|weekdays?';\nconst reReltextnumber = 'first|second|third|fourth|fifth|sixth|seventh|eighth?|ninth|tenth|eleventh|twelfth';\nconst reReltexttext = 'next|last|previous|this';\nconst reReltextunit = '(?:second|sec|minute|min|hour|day|fortnight|forthnight|month|year)s?|weeks|' + reDaytext;\nconst reYear = '([0-9]{1,4})';\nconst reYear2 = '([0-9]{2})';\nconst reYear4 = '([0-9]{4})';\nconst reYear4withSign = '([+-]?[0-9]{4})';\nconst reMonth = '(1[0-2]|0?[0-9])';\nconst reMonthlz = '(0[0-9]|1[0-2])';\nconst reDay = '(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)';\nconst reDaylz = '(0[0-9]|[1-2][0-9]|3[01])';\nconst reMonthFull = 'january|february|march|april|may|june|july|august|september|october|november|december';\nconst reMonthAbbr = 'jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec';\nconst reMonthroman = 'i[vx]|vi{0,3}|xi{0,2}|i{1,3}';\nconst reMonthText = '(' + reMonthFull + '|' + reMonthAbbr + '|' + reMonthroman + ')';\nconst reTzCorrection = '((?:GMT)?([+-])' + reHour24 + ':?' + reMinute + '?)';\nconst reTzAbbr = '\\\\(?([a-zA-Z]{1,6})\\\\)?';\nconst reDayOfYear = '(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])';\nconst reWeekOfYear = '(0[1-9]|[1-4][0-9]|5[0-3])';\nconst reDateNoYear = reMonthText + '[ .\\\\t-]*' + reDay + '[,.stndrh\\\\t ]*';\nfunction processMeridian(hour, meridian) {\n const normalizedMeridian = meridian?.toLowerCase();\n switch (normalizedMeridian) {\n case 'a':\n hour += hour === 12 ? -12 : 0;\n break;\n case 'p':\n hour += hour !== 12 ? 12 : 0;\n break;\n }\n return hour;\n}\nfunction processYear(yearStr) {\n let year = +yearStr;\n if (yearStr.length < 4 && year < 100) {\n year += year < 70 ? 2000 : 1900;\n }\n return year;\n}\nfunction lookupMonth(monthStr) {\n const monthLookup = {\n jan: 0,\n january: 0,\n i: 0,\n feb: 1,\n february: 1,\n ii: 1,\n mar: 2,\n march: 2,\n iii: 2,\n apr: 3,\n april: 3,\n iv: 3,\n may: 4,\n v: 4,\n jun: 5,\n june: 5,\n vi: 5,\n jul: 6,\n july: 6,\n vii: 6,\n aug: 7,\n august: 7,\n viii: 7,\n sep: 8,\n sept: 8,\n september: 8,\n ix: 8,\n oct: 9,\n october: 9,\n x: 9,\n nov: 10,\n november: 10,\n xi: 10,\n dec: 11,\n december: 11,\n xii: 11,\n };\n return monthLookup[monthStr.toLowerCase()] ?? Number.NaN;\n}\nfunction lookupWeekday(dayStr, desiredSundayNumber = 0) {\n const dayNumbers = {\n mon: 1,\n monday: 1,\n tue: 2,\n tuesday: 2,\n wed: 3,\n wednesday: 3,\n thu: 4,\n thursday: 4,\n fri: 5,\n friday: 5,\n sat: 6,\n saturday: 6,\n sun: 0,\n sunday: 0,\n };\n return dayNumbers[dayStr.toLowerCase()] || desiredSundayNumber;\n}\nfunction lookupRelative(relText) {\n const relativeNumbers = {\n last: -1,\n previous: -1,\n this: 0,\n first: 1,\n next: 1,\n second: 2,\n third: 3,\n fourth: 4,\n fifth: 5,\n sixth: 6,\n seventh: 7,\n eight: 8,\n eighth: 8,\n ninth: 9,\n tenth: 10,\n eleventh: 11,\n twelfth: 12,\n };\n const relativeBehavior = {\n this: 1,\n };\n const relTextLower = relText.toLowerCase();\n return {\n amount: relativeNumbers[relTextLower] ?? 0,\n behavior: relativeBehavior[relTextLower] || 0,\n };\n}\nfunction processTzCorrection(tzOffset, oldValue = Number.NaN) {\n const reTzCorrectionLoose = /(?:GMT)?([+-])(\\d+)(:?)(\\d{0,2})/i;\n const tzMatch = tzOffset?.match(reTzCorrectionLoose);\n if (!tzMatch) {\n return oldValue;\n }\n const sign = tzMatch[1] === '-' ? -1 : 1;\n let hours = +(tzMatch[2] ?? 0);\n let minutes = +(tzMatch[4] ?? 0);\n if (!tzMatch[4] && !tzMatch[3]) {\n minutes = Math.floor(hours % 100);\n hours = Math.floor(hours / 100);\n }\n // timezone offset in seconds\n return sign * (hours * 60 + minutes) * 60;\n}\n// tz abbrevation : tz offset in seconds\nconst tzAbbrOffsets = {\n acdt: 37800,\n acst: 34200,\n addt: -7200,\n adt: -10800,\n aedt: 39600,\n aest: 36000,\n ahdt: -32400,\n ahst: -36000,\n akdt: -28800,\n akst: -32400,\n amt: -13840,\n apt: -10800,\n ast: -14400,\n awdt: 32400,\n awst: 28800,\n awt: -10800,\n bdst: 7200,\n bdt: -36000,\n bmt: -14309,\n bst: 3600,\n cast: 34200,\n cat: 7200,\n cddt: -14400,\n cdt: -18000,\n cemt: 10800,\n cest: 7200,\n cet: 3600,\n cmt: -15408,\n cpt: -18000,\n cst: -21600,\n cwt: -18000,\n chst: 36000,\n dmt: -1521,\n eat: 10800,\n eddt: -10800,\n edt: -14400,\n eest: 10800,\n eet: 7200,\n emt: -26248,\n ept: -14400,\n est: -18000,\n ewt: -14400,\n ffmt: -14660,\n fmt: -4056,\n gdt: 39600,\n gmt: 0,\n gst: 36000,\n hdt: -34200,\n hkst: 32400,\n hkt: 28800,\n hmt: -19776,\n hpt: -34200,\n hst: -36000,\n hwt: -34200,\n iddt: 14400,\n idt: 10800,\n imt: 25025,\n ist: 7200,\n jdt: 36000,\n jmt: 8440,\n jst: 32400,\n kdt: 36000,\n kmt: 5736,\n kst: 30600,\n lst: 9394,\n mddt: -18000,\n mdst: 16279,\n mdt: -21600,\n mest: 7200,\n met: 3600,\n mmt: 9017,\n mpt: -21600,\n msd: 14400,\n msk: 10800,\n mst: -25200,\n mwt: -21600,\n nddt: -5400,\n ndt: -9052,\n npt: -9000,\n nst: -12600,\n nwt: -9000,\n nzdt: 46800,\n nzmt: 41400,\n nzst: 43200,\n pddt: -21600,\n pdt: -25200,\n pkst: 21600,\n pkt: 18000,\n plmt: 25590,\n pmt: -13236,\n ppmt: -17340,\n ppt: -25200,\n pst: -28800,\n pwt: -25200,\n qmt: -18840,\n rmt: 5794,\n sast: 7200,\n sdmt: -16800,\n sjmt: -20173,\n smt: -13884,\n sst: -39600,\n tbmt: 10751,\n tmt: 12344,\n uct: 0,\n utc: 0,\n wast: 7200,\n wat: 3600,\n wemt: 7200,\n west: 3600,\n wet: 0,\n wib: 25200,\n wita: 28800,\n wit: 32400,\n wmt: 5040,\n yddt: -25200,\n ydt: -28800,\n ypt: -28800,\n yst: -32400,\n ywt: -28800,\n a: 3600,\n b: 7200,\n c: 10800,\n d: 14400,\n e: 18000,\n f: 21600,\n g: 25200,\n h: 28800,\n i: 32400,\n k: 36000,\n l: 39600,\n m: 43200,\n n: -3600,\n o: -7200,\n p: -10800,\n q: -14400,\n r: -18000,\n s: -21600,\n t: -25200,\n u: -28800,\n v: -32400,\n w: -36000,\n x: -39600,\n y: -43200,\n z: 0,\n};\nconst formats = {\n yesterday: {\n regex: /^yesterday/i,\n name: 'yesterday',\n callback() {\n this.rd -= 1;\n return this.resetTime();\n },\n },\n now: {\n regex: /^now/i,\n name: 'now',\n // do nothing\n },\n noon: {\n regex: /^noon/i,\n name: 'noon',\n callback() {\n return this.resetTime() && this.time(12, 0, 0, 0);\n },\n },\n midnightOrToday: {\n regex: /^(midnight|today)/i,\n name: 'midnight | today',\n callback() {\n return this.resetTime();\n },\n },\n tomorrow: {\n regex: /^tomorrow/i,\n name: 'tomorrow',\n callback() {\n this.rd += 1;\n return this.resetTime();\n },\n },\n timestamp: {\n regex: /^@(-?\\d+)/i,\n name: 'timestamp',\n callback(match, timestamp) {\n this.rs += +timestamp;\n this.y = 1970;\n this.m = 0;\n this.d = 1;\n this.dates = 0;\n return this.resetTime() && this.zone(0);\n },\n },\n firstOrLastDay: {\n regex: /^(first|last) day of/i,\n name: 'firstdayof | lastdayof',\n callback(match, day) {\n if (day.toLowerCase() === 'first') {\n this.firstOrLastDayOfMonth = 1;\n }\n else {\n this.firstOrLastDayOfMonth = -1;\n }\n },\n },\n backOrFrontOf: {\n regex: new RegExp('^(back|front) of ' + reHour24 + reSpaceOpt + reMeridian + '?', 'i'),\n name: 'backof | frontof',\n callback(match, side, hours, meridian) {\n const back = side.toLowerCase() === 'back';\n let hour = +hours;\n let minute = 15;\n if (!back) {\n hour -= 1;\n minute = 45;\n }\n hour = processMeridian(hour, meridian);\n return this.resetTime() && this.time(hour, minute, 0, 0);\n },\n },\n weekdayOf: {\n regex: new RegExp('^(' +\n reReltextnumber +\n '|' +\n reReltexttext +\n ')' +\n reSpace +\n '(' +\n reDayfull +\n '|' +\n reDayabbr +\n ')' +\n reSpace +\n 'of', 'i'),\n name: 'weekdayof',\n // todo\n },\n mssqltime: {\n regex: new RegExp('^' + reHour12 + ':' + reMinutelz + ':' + reSecondlz + '[:.]([0-9]+)' + reMeridian, 'i'),\n name: 'mssqltime',\n callback(match, hour, minute, second, frac, meridian) {\n return this.time(processMeridian(+hour, meridian), +minute, +second, +frac.substr(0, 3));\n },\n },\n oracledate: {\n regex: /^(\\d{2})-([A-Z]{3})-(\\d{2})$/i,\n name: 'd-M-y',\n callback(match, day, monthText, year) {\n const monthByName = {\n JAN: 0,\n FEB: 1,\n MAR: 2,\n APR: 3,\n MAY: 4,\n JUN: 5,\n JUL: 6,\n AUG: 7,\n SEP: 8,\n OCT: 9,\n NOV: 10,\n DEC: 11,\n };\n const month = monthByName[monthText.toUpperCase()] ?? Number.NaN;\n return this.ymd(2000 + parseInt(year, 10), month, parseInt(day, 10));\n },\n },\n timeLong12: {\n regex: new RegExp('^' + reHour12 + '[:.]' + reMinute + '[:.]' + reSecondlz + reSpaceOpt + reMeridian, 'i'),\n name: 'timelong12',\n callback(match, hour, minute, second, meridian) {\n return this.time(processMeridian(+hour, meridian), +minute, +second, 0);\n },\n },\n timeShort12: {\n regex: new RegExp('^' + reHour12 + '[:.]' + reMinutelz + reSpaceOpt + reMeridian, 'i'),\n name: 'timeshort12',\n callback(match, hour, minute, meridian) {\n return this.time(processMeridian(+hour, meridian), +minute, 0, 0);\n },\n },\n timeTiny12: {\n regex: new RegExp('^' + reHour12 + reSpaceOpt + reMeridian, 'i'),\n name: 'timetiny12',\n callback(match, hour, meridian) {\n return this.time(processMeridian(+hour, meridian), 0, 0, 0);\n },\n },\n soap: {\n regex: new RegExp('^' +\n reYear4 +\n '-' +\n reMonthlz +\n '-' +\n reDaylz +\n 'T' +\n reHour24lz +\n ':' +\n reMinutelz +\n ':' +\n reSecondlz +\n reFrac +\n reTzCorrection +\n '?', 'i'),\n name: 'soap',\n callback(match, year, month, day, hour, minute, second, frac, tzCorrection) {\n return (this.ymd(+year, +month - 1, +day) &&\n this.time(+hour, +minute, +second, +frac.substr(0, 3)) &&\n this.zone(processTzCorrection(tzCorrection)));\n },\n },\n wddx: {\n regex: new RegExp('^' + reYear4 + '-' + reMonth + '-' + reDay + 'T' + reHour24 + ':' + reMinute + ':' + reSecond),\n name: 'wddx',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n exif: {\n regex: new RegExp('^' + reYear4 + ':' + reMonthlz + ':' + reDaylz + ' ' + reHour24lz + ':' + reMinutelz + ':' + reSecondlz, 'i'),\n name: 'exif',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n xmlRpc: {\n regex: new RegExp('^' + reYear4 + reMonthlz + reDaylz + 'T' + reHour24 + ':' + reMinutelz + ':' + reSecondlz),\n name: 'xmlrpc',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n xmlRpcNoColon: {\n regex: new RegExp('^' + reYear4 + reMonthlz + reDaylz + '[Tt]' + reHour24 + reMinutelz + reSecondlz),\n name: 'xmlrpcnocolon',\n callback(match, year, month, day, hour, minute, second) {\n return this.ymd(+year, +month - 1, +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n clf: {\n regex: new RegExp('^' +\n reDay +\n '/(' +\n reMonthAbbr +\n ')/' +\n reYear4 +\n ':' +\n reHour24lz +\n ':' +\n reMinutelz +\n ':' +\n reSecondlz +\n reSpace +\n reTzCorrection, 'i'),\n name: 'clf',\n callback(match, day, month, year, hour, minute, second, tzCorrection) {\n return (this.ymd(+year, lookupMonth(month), +day) &&\n this.time(+hour, +minute, +second, 0) &&\n this.zone(processTzCorrection(tzCorrection)));\n },\n },\n iso8601long: {\n regex: new RegExp('^t?' + reHour24 + '[:.]' + reMinute + '[:.]' + reSecond + reFrac, 'i'),\n name: 'iso8601long',\n callback(match, hour, minute, second, frac) {\n return this.time(+hour, +minute, +second, +frac.substr(0, 3));\n },\n },\n dateTextual: {\n regex: new RegExp('^' + reMonthText + '[ .\\\\t-]*' + reDay + '[,.stndrh\\\\t ]+' + reYear, 'i'),\n name: 'datetextual',\n callback(match, month, day, year) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n pointedDate4: {\n regex: new RegExp('^' + reDay + '[.\\\\t-]' + reMonth + '[.-]' + reYear4),\n name: 'pointeddate4',\n callback(match, day, month, year) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n pointedDate2: {\n regex: new RegExp('^' + reDay + '[.\\\\t]' + reMonth + '\\\\.' + reYear2),\n name: 'pointeddate2',\n callback(match, day, month, year) {\n return this.ymd(processYear(year), +month - 1, +day);\n },\n },\n timeLong24: {\n regex: new RegExp('^t?' + reHour24 + '[:.]' + reMinute + '[:.]' + reSecond),\n name: 'timelong24',\n callback(match, hour, minute, second) {\n return this.time(+hour, +minute, +second, 0);\n },\n },\n dateNoColon: {\n regex: new RegExp('^' + reYear4 + reMonthlz + reDaylz),\n name: 'datenocolon',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n pgydotd: {\n regex: new RegExp('^' + reYear4 + '\\\\.?' + reDayOfYear),\n name: 'pgydotd',\n callback(match, year, day) {\n return this.ymd(+year, 0, +day);\n },\n },\n timeShort24: {\n regex: new RegExp('^t?' + reHour24 + '[:.]' + reMinute, 'i'),\n name: 'timeshort24',\n callback(match, hour, minute) {\n return this.time(+hour, +minute, 0, 0);\n },\n },\n iso8601noColon: {\n regex: new RegExp('^t?' + reHour24lz + reMinutelz + reSecondlz, 'i'),\n name: 'iso8601nocolon',\n callback(match, hour, minute, second) {\n return this.time(+hour, +minute, +second, 0);\n },\n },\n iso8601dateSlash: {\n // eventhough the trailing slash is optional in PHP\n // here it's mandatory and inputs without the slash\n // are handled by dateslash\n regex: new RegExp('^' + reYear4 + '/' + reMonthlz + '/' + reDaylz + '/'),\n name: 'iso8601dateslash',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n dateSlash: {\n regex: new RegExp('^' + reYear4 + '/' + reMonth + '/' + reDay),\n name: 'dateslash',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n american: {\n regex: new RegExp('^' + reMonth + '/' + reDay + '/' + reYear),\n name: 'american',\n callback(match, month, day, year) {\n return this.ymd(processYear(year), +month - 1, +day);\n },\n },\n americanShort: {\n regex: new RegExp('^' + reMonth + '/' + reDay),\n name: 'americanshort',\n callback(match, month, day) {\n return this.ymd(this.y, +month - 1, +day);\n },\n },\n gnuDateShortOrIso8601date2: {\n // iso8601date2 is complete subset of gnudateshort\n regex: new RegExp('^' + reYear + '-' + reMonth + '-' + reDay),\n name: 'gnudateshort | iso8601date2',\n callback(match, year, month, day) {\n return this.ymd(processYear(year), +month - 1, +day);\n },\n },\n iso8601date4: {\n regex: new RegExp('^' + reYear4withSign + '-' + reMonthlz + '-' + reDaylz),\n name: 'iso8601date4',\n callback(match, year, month, day) {\n return this.ymd(+year, +month - 1, +day);\n },\n },\n gnuNoColon: {\n regex: new RegExp('^t?' + reHour24lz + reMinutelz, 'i'),\n name: 'gnunocolon',\n callback(match, hour, minute) {\n // this rule is a special case\n // if time was already set once by any preceding rule, it sets the captured value as year\n switch (this.times) {\n case 0:\n return this.time(+hour, +minute, 0, this.f);\n case 1:\n this.y = +hour * 100 + +minute;\n this.times++;\n return true;\n default:\n return false;\n }\n },\n },\n gnuDateShorter: {\n regex: new RegExp('^' + reYear4 + '-' + reMonth),\n name: 'gnudateshorter',\n callback(match, year, month) {\n return this.ymd(+year, +month - 1, 1);\n },\n },\n pgTextReverse: {\n // note: allowed years are from 32-9999\n // years below 32 should be treated as days in datefull\n regex: new RegExp('^' + '(\\\\d{3,4}|[4-9]\\\\d|3[2-9])-(' + reMonthAbbr + ')-' + reDaylz, 'i'),\n name: 'pgtextreverse',\n callback(match, year, month, day) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n dateFull: {\n regex: new RegExp('^' + reDay + '[ \\\\t.-]*' + reMonthText + '[ \\\\t.-]*' + reYear, 'i'),\n name: 'datefull',\n callback(match, day, month, year) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n dateNoDay: {\n regex: new RegExp('^' + reMonthText + '[ .\\\\t-]*' + reYear4, 'i'),\n name: 'datenoday',\n callback(match, month, year) {\n return this.ymd(+year, lookupMonth(month), 1);\n },\n },\n dateNoDayRev: {\n regex: new RegExp('^' + reYear4 + '[ .\\\\t-]*' + reMonthText, 'i'),\n name: 'datenodayrev',\n callback(match, year, month) {\n return this.ymd(+year, lookupMonth(month), 1);\n },\n },\n pgTextShort: {\n regex: new RegExp('^(' + reMonthAbbr + ')-' + reDaylz + '-' + reYear, 'i'),\n name: 'pgtextshort',\n callback(match, month, day, year) {\n return this.ymd(processYear(year), lookupMonth(month), +day);\n },\n },\n dateNoYear: {\n regex: new RegExp('^' + reDateNoYear, 'i'),\n name: 'datenoyear',\n callback(match, month, day) {\n return this.ymd(this.y, lookupMonth(month), +day);\n },\n },\n dateNoYearRev: {\n regex: new RegExp('^' + reDay + '[ .\\\\t-]*' + reMonthText, 'i'),\n name: 'datenoyearrev',\n callback(match, day, month) {\n return this.ymd(this.y, lookupMonth(month), +day);\n },\n },\n isoWeekDay: {\n regex: new RegExp('^' + reYear4 + '-?W' + reWeekOfYear + '(?:-?([0-7]))?'),\n name: 'isoweekday | isoweek',\n callback(match, year, week, day) {\n const dayOfWeek = day ? +day : 1;\n if (!this.ymd(+year, 0, 1)) {\n return false;\n }\n // get day of week for Jan 1st\n let jan1DayOfWeek = new Date(this.y, this.m, this.d).getDay();\n // and use the day to figure out the offset for day 1 of week 1\n jan1DayOfWeek = 0 - (jan1DayOfWeek > 4 ? jan1DayOfWeek - 7 : jan1DayOfWeek);\n this.rd += jan1DayOfWeek + (+week - 1) * 7 + dayOfWeek;\n return true;\n },\n },\n relativeText: {\n regex: new RegExp('^(' + reReltextnumber + '|' + reReltexttext + ')' + reSpace + '(' + reReltextunit + ')', 'i'),\n name: 'relativetext',\n callback(match, relValue, relUnit) {\n // todo: implement handling of 'this time-unit'\n // biome-ignore lint/correctness/noUnusedVariables: behavior reserved for future use\n const { amount, behavior } = lookupRelative(relValue);\n switch (relUnit.toLowerCase()) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n this.rs += amount;\n break;\n case 'min':\n case 'mins':\n case 'minute':\n case 'minutes':\n this.ri += amount;\n break;\n case 'hour':\n case 'hours':\n this.rh += amount;\n break;\n case 'day':\n case 'days':\n this.rd += amount;\n break;\n case 'fortnight':\n case 'fortnights':\n case 'forthnight':\n case 'forthnights':\n this.rd += amount * 14;\n break;\n case 'week':\n case 'weeks':\n this.rd += amount * 7;\n break;\n case 'month':\n case 'months':\n this.rm += amount;\n break;\n case 'year':\n case 'years':\n this.ry += amount;\n break;\n case 'mon':\n case 'monday':\n case 'tue':\n case 'tuesday':\n case 'wed':\n case 'wednesday':\n case 'thu':\n case 'thursday':\n case 'fri':\n case 'friday':\n case 'sat':\n case 'saturday':\n case 'sun':\n case 'sunday':\n this.resetTime();\n this.weekday = lookupWeekday(relUnit, 7);\n this.weekdayBehavior = 1;\n this.rd += (amount > 0 ? amount - 1 : amount) * 7;\n break;\n case 'weekday':\n case 'weekdays':\n // todo\n break;\n }\n },\n },\n relative: {\n regex: new RegExp('^([+-]*)[ \\\\t]*(\\\\d+)' + reSpaceOpt + '(' + reReltextunit + '|week)', 'i'),\n name: 'relative',\n callback(match, signs, relValue, relUnit) {\n const minuses = signs.replace(/[^-]/g, '').length;\n const amount = +relValue * Math.pow(-1, minuses);\n switch (relUnit.toLowerCase()) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n this.rs += amount;\n break;\n case 'min':\n case 'mins':\n case 'minute':\n case 'minutes':\n this.ri += amount;\n break;\n case 'hour':\n case 'hours':\n this.rh += amount;\n break;\n case 'day':\n case 'days':\n this.rd += amount;\n break;\n case 'fortnight':\n case 'fortnights':\n case 'forthnight':\n case 'forthnights':\n this.rd += amount * 14;\n break;\n case 'week':\n case 'weeks':\n this.rd += amount * 7;\n break;\n case 'month':\n case 'months':\n this.rm += amount;\n break;\n case 'year':\n case 'years':\n this.ry += amount;\n break;\n case 'mon':\n case 'monday':\n case 'tue':\n case 'tuesday':\n case 'wed':\n case 'wednesday':\n case 'thu':\n case 'thursday':\n case 'fri':\n case 'friday':\n case 'sat':\n case 'saturday':\n case 'sun':\n case 'sunday':\n this.resetTime();\n this.weekday = lookupWeekday(relUnit, 7);\n this.weekdayBehavior = 1;\n this.rd += (amount > 0 ? amount - 1 : amount) * 7;\n break;\n case 'weekday':\n case 'weekdays':\n // todo\n break;\n }\n },\n },\n dayText: {\n regex: new RegExp('^(' + reDaytext + ')', 'i'),\n name: 'daytext',\n callback(match, dayText) {\n this.resetTime();\n this.weekday = lookupWeekday(dayText, 0);\n if (this.weekdayBehavior !== 2) {\n this.weekdayBehavior = 1;\n }\n },\n },\n relativeTextWeek: {\n regex: new RegExp('^(' + reReltexttext + ')' + reSpace + 'week', 'i'),\n name: 'relativetextweek',\n callback(match, relText) {\n this.weekdayBehavior = 2;\n switch (relText.toLowerCase()) {\n case 'this':\n this.rd += 0;\n break;\n case 'next':\n this.rd += 7;\n break;\n case 'last':\n case 'previous':\n this.rd -= 7;\n break;\n }\n if (isNaN(this.weekday)) {\n this.weekday = 1;\n }\n },\n },\n monthFullOrMonthAbbr: {\n regex: new RegExp('^(' + reMonthFull + '|' + reMonthAbbr + ')', 'i'),\n name: 'monthfull | monthabbr',\n callback(match, month) {\n return this.ymd(this.y, lookupMonth(month), this.d);\n },\n },\n tzCorrection: {\n regex: new RegExp('^' + reTzCorrection, 'i'),\n name: 'tzcorrection',\n callback(tzCorrection) {\n return this.zone(processTzCorrection(tzCorrection));\n },\n },\n tzAbbr: {\n regex: new RegExp('^' + reTzAbbr),\n name: 'tzabbr',\n callback(match, abbr) {\n const offset = tzAbbrOffsets[abbr.toLowerCase()];\n if (offset == null || Number.isNaN(offset)) {\n return false;\n }\n return this.zone(offset);\n },\n },\n ago: {\n regex: /^ago/i,\n name: 'ago',\n callback() {\n this.ry = -this.ry;\n this.rm = -this.rm;\n this.rd = -this.rd;\n this.rh = -this.rh;\n this.ri = -this.ri;\n this.rs = -this.rs;\n this.rf = -this.rf;\n },\n },\n year4: {\n regex: new RegExp('^' + reYear4),\n name: 'year4',\n callback(match, year) {\n this.y = +year;\n return true;\n },\n },\n whitespace: {\n regex: /^[ .,\\t]+/,\n name: 'whitespace',\n // do nothing\n },\n dateShortWithTimeLong: {\n regex: new RegExp('^' + reDateNoYear + 't?' + reHour24 + '[:.]' + reMinute + '[:.]' + reSecond, 'i'),\n name: 'dateshortwithtimelong',\n callback(match, month, day, hour, minute, second) {\n return this.ymd(this.y, lookupMonth(month), +day) && this.time(+hour, +minute, +second, 0);\n },\n },\n dateShortWithTimeLong12: {\n regex: new RegExp('^' + reDateNoYear + reHour12 + '[:.]' + reMinute + '[:.]' + reSecondlz + reSpaceOpt + reMeridian, 'i'),\n name: 'dateshortwithtimelong12',\n callback(match, month, day, hour, minute, second, meridian) {\n return (this.ymd(this.y, lookupMonth(month), +day) && this.time(processMeridian(+hour, meridian), +minute, +second, 0));\n },\n },\n dateShortWithTimeShort: {\n regex: new RegExp('^' + reDateNoYear + 't?' + reHour24 + '[:.]' + reMinute, 'i'),\n name: 'dateshortwithtimeshort',\n callback(match, month, day, hour, minute) {\n return this.ymd(this.y, lookupMonth(month), +day) && this.time(+hour, +minute, 0, 0);\n },\n },\n dateShortWithTimeShort12: {\n regex: new RegExp('^' + reDateNoYear + reHour12 + '[:.]' + reMinutelz + reSpaceOpt + reMeridian, 'i'),\n name: 'dateshortwithtimeshort12',\n callback(match, month, day, hour, minute, meridian) {\n return this.ymd(this.y, lookupMonth(month), +day) && this.time(processMeridian(+hour, meridian), +minute, 0, 0);\n },\n },\n};\nconst resultProto = {\n // date\n y: NaN,\n m: NaN,\n d: NaN,\n // time\n h: NaN,\n i: NaN,\n s: NaN,\n f: NaN,\n // relative shifts\n ry: 0,\n rm: 0,\n rd: 0,\n rh: 0,\n ri: 0,\n rs: 0,\n rf: 0,\n // weekday related shifts\n weekday: NaN,\n weekdayBehavior: 0,\n // first or last day of month\n // 0 none, 1 first, -1 last\n firstOrLastDayOfMonth: 0,\n // timezone correction in minutes\n z: NaN,\n // counters\n dates: 0,\n times: 0,\n zones: 0,\n // helper functions\n ymd(y, m, d) {\n if (this.dates > 0) {\n return false;\n }\n this.dates++;\n this.y = y;\n this.m = m;\n this.d = d;\n return true;\n },\n time(h, i, s, f) {\n if (this.times > 0) {\n return false;\n }\n this.times++;\n this.h = h;\n this.i = i;\n this.s = s;\n this.f = f;\n return true;\n },\n resetTime() {\n this.h = 0;\n this.i = 0;\n this.s = 0;\n this.f = 0;\n this.times = 0;\n return true;\n },\n zone(minutes) {\n if (this.zones <= 1) {\n this.zones++;\n this.z = minutes;\n return true;\n }\n return false;\n },\n toDate(relativeTo) {\n if (this.dates && !this.times) {\n this.h = this.i = this.s = this.f = 0;\n }\n // fill holes\n if (isNaN(this.y)) {\n this.y = relativeTo.getFullYear();\n }\n if (isNaN(this.m)) {\n this.m = relativeTo.getMonth();\n }\n if (isNaN(this.d)) {\n this.d = relativeTo.getDate();\n }\n if (isNaN(this.h)) {\n this.h = relativeTo.getHours();\n }\n if (isNaN(this.i)) {\n this.i = relativeTo.getMinutes();\n }\n if (isNaN(this.s)) {\n this.s = relativeTo.getSeconds();\n }\n if (isNaN(this.f)) {\n this.f = relativeTo.getMilliseconds();\n }\n // adjust special early\n switch (this.firstOrLastDayOfMonth) {\n case 1:\n this.d = 1;\n break;\n case -1:\n this.d = 0;\n this.m += 1;\n break;\n }\n if (!isNaN(this.weekday)) {\n const date = new Date(relativeTo.getTime());\n date.setFullYear(this.y, this.m, this.d);\n date.setHours(this.h, this.i, this.s, this.f);\n const dow = date.getDay();\n if (this.weekdayBehavior === 2) {\n // To make \"this week\" work, where the current day of week is a \"sunday\"\n if (dow === 0 && this.weekday !== 0) {\n this.weekday = -6;\n }\n // To make \"sunday this week\" work, where the current day of week is not a \"sunday\"\n if (this.weekday === 0 && dow !== 0) {\n this.weekday = 7;\n }\n this.d -= dow;\n this.d += this.weekday;\n }\n else {\n let diff = this.weekday - dow;\n // some PHP magic\n if ((this.rd < 0 && diff < 0) || (this.rd >= 0 && diff <= -this.weekdayBehavior)) {\n diff += 7;\n }\n if (this.weekday >= 0) {\n this.d += diff;\n }\n else {\n this.d -= 7 - (Math.abs(this.weekday) - dow);\n }\n this.weekday = NaN;\n }\n }\n // adjust relative\n this.y += this.ry;\n this.m += this.rm;\n this.d += this.rd;\n this.h += this.rh;\n this.i += this.ri;\n this.s += this.rs;\n this.f += this.rf;\n this.ry = this.rm = this.rd = 0;\n this.rh = this.ri = this.rs = this.rf = 0;\n const result = new Date(relativeTo.getTime());\n // since Date constructor treats years <= 99 as 1900+\n // it can't be used, thus this weird way\n result.setFullYear(this.y, this.m, this.d);\n result.setHours(this.h, this.i, this.s, this.f);\n // note: this is done twice in PHP\n // early when processing special relatives\n // and late\n // todo: check if the logic can be reduced\n // to just one time action\n switch (this.firstOrLastDayOfMonth) {\n case 1:\n result.setDate(1);\n break;\n case -1:\n result.setMonth(result.getMonth() + 1, 0);\n break;\n }\n // adjust timezone\n if (!isNaN(this.z) && result.getTimezoneOffset() !== this.z) {\n result.setUTCFullYear(result.getFullYear(), result.getMonth(), result.getDate());\n result.setUTCHours(result.getHours(), result.getMinutes(), result.getSeconds() - this.z, result.getMilliseconds());\n }\n return result;\n },\n};\nfunction strtotime(str, now) {\n // discuss at: https://locutus.io/php/strtotime/\n // original by: Caio Ariede (https://caioariede.com)\n // improved by: Kevin van Zonneveld (https://kvz.io)\n // improved by: Caio Ariede (https://caioariede.com)\n // improved by: A. Matías Quezada (https://amatiasq.com)\n // improved by: preuter\n // improved by: Brett Zamir (https://brett-zamir.me)\n // improved by: Mirko Faber\n // input by: David\n // bugfixed by: Wagner B. Soares\n // bugfixed by: Artur Tchernychev\n // bugfixed by: Stephan Bösch-Plepelits (https://github.com/plepe)\n // reimplemented by: Rafał Kukawski\n // note 1: Examples all have a fixed timestamp to prevent\n // note 1: tests to fail because of variable time(zones)\n // example 1: strtotime('+1 day', 1129633200)\n // returns 1: 1129719600\n // example 2: strtotime('+1 week 2 days 4 hours 2 seconds', 1129633200)\n // returns 2: 1130425202\n // example 3: strtotime('last month', 1129633200)\n // returns 3: 1127041200\n // example 4: strtotime('2009-05-04 08:30:00+00')\n // returns 4: 1241425800\n // example 5: strtotime('2009-05-04 08:30:00+02:00')\n // returns 5: 1241418600\n // example 6: strtotime('2009-05-04 08:30:00 YWT')\n // returns 6: 1241454600\n // example 7: strtotime('10-JUL-17')\n // returns 7: 1499644800\n const nowSeconds = now == null ? Math.floor(Date.now() / 1000) : now;\n str = String(str);\n // the rule order is important\n // if multiple rules match, the longest match wins\n // if multiple rules match the same string, the first match wins\n const rules = [\n formats.yesterday,\n formats.now,\n formats.noon,\n formats.midnightOrToday,\n formats.tomorrow,\n formats.timestamp,\n formats.firstOrLastDay,\n formats.backOrFrontOf,\n // formats.weekdayOf, // not yet implemented\n formats.timeTiny12,\n formats.timeShort12,\n formats.timeLong12,\n formats.mssqltime,\n formats.oracledate,\n formats.timeShort24,\n formats.timeLong24,\n formats.iso8601long,\n formats.gnuNoColon,\n formats.iso8601noColon,\n formats.americanShort,\n formats.american,\n formats.iso8601date4,\n formats.iso8601dateSlash,\n formats.dateSlash,\n formats.gnuDateShortOrIso8601date2,\n formats.gnuDateShorter,\n formats.dateFull,\n formats.pointedDate4,\n formats.pointedDate2,\n formats.dateNoDay,\n formats.dateNoDayRev,\n formats.dateTextual,\n formats.dateNoYear,\n formats.dateNoYearRev,\n formats.dateNoColon,\n formats.xmlRpc,\n formats.xmlRpcNoColon,\n formats.soap,\n formats.wddx,\n formats.exif,\n formats.pgydotd,\n formats.isoWeekDay,\n formats.pgTextShort,\n formats.pgTextReverse,\n formats.clf,\n formats.year4,\n formats.ago,\n formats.dayText,\n formats.relativeTextWeek,\n formats.relativeText,\n formats.monthFullOrMonthAbbr,\n formats.tzCorrection,\n formats.tzAbbr,\n formats.dateShortWithTimeShort12,\n formats.dateShortWithTimeLong12,\n formats.dateShortWithTimeShort,\n formats.dateShortWithTimeLong,\n formats.relative,\n formats.whitespace,\n ];\n const result = { ...resultProto };\n while (str.length) {\n let longestMatch = null;\n let finalRule = null;\n for (const format of rules) {\n const match = str.match(format.regex);\n if (match) {\n if (!longestMatch || match[0].length > longestMatch[0].length) {\n longestMatch = match;\n finalRule = format;\n }\n }\n }\n if (!finalRule || !longestMatch) {\n return false;\n }\n if (finalRule.callback && finalRule.callback.apply(result, longestMatch) === false) {\n return false;\n }\n str = str.substr(longestMatch[0].length);\n finalRule = null;\n longestMatch = null;\n }\n return Math.floor(result.toDate(new Date(nowSeconds * 1000)).getTime() / 1000);\n}\n// php/datetime/date_parse (target function module)\nfunction date_parse(date) {\n // discuss at: https://locutus.io/php/date_parse/\n // original by: Brett Zamir (https://brett-zamir.me)\n // example 1: date_parse('2006-12-12 10:00:00')\n // returns 1: {year : 2006, month: 12, day: 12, hour: 10, minute: 0, second: 0, fraction: 0, is_localtime: false}\n let ts;\n try {\n ts = strtotime(date, undefined);\n }\n catch (_e) {\n ts = false;\n }\n if (!ts) {\n return false;\n }\n const dt = new Date(ts * 1000);\n const retObj = {\n year: dt.getFullYear(),\n month: dt.getMonth() + 1,\n day: dt.getDate(),\n hour: dt.getHours(),\n minute: dt.getMinutes(),\n second: dt.getSeconds(),\n fraction: Number.parseFloat(`0.${dt.getMilliseconds()}`),\n is_localtime: dt.getTimezoneOffset() !== 0,\n };\n return retObj;\n}" const __locutus_eval_function = (compiledCode: string): ((...args: unknown[]) => unknown) => { const evaluator = new Function('require', compiledCode + '\nreturn ' + __locutus_func_name + ';') return evaluator(__locutus_source_require) as (...args: unknown[]) => unknown } const __locutus_eval_module_export = (compiledCode: string, exportName: string): ((...args: unknown[]) => unknown) => { const module = { exports: {} as { [key: string]: unknown } } const exports = module.exports const evaluator = new Function('exports', 'module', 'require', compiledCode) evaluator(exports, module, __locutus_source_require) return module.exports[exportName] as (...args: unknown[]) => unknown } const __locutus_module_js_fn = __locutus_eval_module_export(__locutus_module_js_code, __locutus_func_name) const __locutus_standalone_ts_fn = __locutus_eval_function(__locutus_standalone_ts_code) const __locutus_standalone_js_fn = __locutus_eval_function(__locutus_standalone_js_code) describe('src/php/datetime/date_parse.ts (tested in test/generated/php/datetime/date_parse.vitest.ts)', function () { it('should pass example 1', function () { const expected = {year : 2006, month: 12, day: 12, hour: 10, minute: 0, second: 0, fraction: 0, is_localtime: false} const __locutus_variants: Array<{ name: string; fn: (...args: unknown[]) => unknown }> = [ { name: "source", fn: __locutus_source_fn }, { name: "module-js", fn: __locutus_module_js_fn }, { name: "standalone-ts", fn: __locutus_standalone_ts_fn }, { name: "standalone-js", fn: __locutus_standalone_js_fn }, ] const __locutus_run_example = (date_parse: typeof __locutus_source_fn) => { return date_parse('2006-12-12 10:00:00') } for (const __locutus_variant of __locutus_variants) { ;(globalThis as { $locutus?: unknown }).$locutus = undefined const result = __locutus_run_example(__locutus_variant.fn as typeof __locutus_source_fn) expect(result).toEqual(expected) } }) })