{"ScriptPreparationCode":"const reSpace = \u0027[ \\\\t]\u002B\u0027\r\nconst reSpaceOpt = \u0027[ \\\\t]*\u0027\r\nconst reMeridian = \u0027(?:([ap])\\\\.?m\\\\.?([\\\\t ]|$))\u0027\r\nconst reHour24 = \u0027(2[0-4]|[01]?[0-9])\u0027\r\nconst reHour24lz = \u0027([01][0-9]|2[0-4])\u0027\r\nconst reHour12 = \u0027(0?[1-9]|1[0-2])\u0027\r\nconst reMinute = \u0027([0-5]?[0-9])\u0027\r\nconst reMinutelz = \u0027([0-5][0-9])\u0027\r\nconst reSecond = \u0027(60|[0-5]?[0-9])\u0027\r\nconst reSecondlz = \u0027(60|[0-5][0-9])\u0027\r\nconst reFrac = \u0027(?:\\\\.([0-9]\u002B))\u0027\r\nconst reDayfull = \u0027sunday|monday|tuesday|wednesday|thursday|friday|saturday\u0027\r\nconst reDayabbr = \u0027sun|mon|tue|wed|thu|fri|sat\u0027\r\nconst reDaytext = reDayfull \u002B \u0027|\u0027 \u002B reDayabbr \u002B \u0027|weekdays?\u0027\r\nconst reReltextnumber = \u0027first|second|third|fourth|fifth|sixth|seventh|eighth?|ninth|tenth|eleventh|twelfth\u0027\r\nconst reReltexttext = \u0027next|last|previous|this\u0027\r\nconst reReltextunit = \u0027(?:second|sec|minute|min|hour|day|fortnight|forthnight|month|year)s?|weeks|\u0027 \u002B reDaytext\r\nconst reYear = \u0027([0-9]{1,4})\u0027\r\nconst reYear2 = \u0027([0-9]{2})\u0027\r\nconst reYear4 = \u0027([0-9]{4})\u0027\r\nconst reYear4withSign = \u0027([\u002B-]?[0-9]{4})\u0027\r\nconst reMonth = \u0027(1[0-2]|0?[0-9])\u0027\r\nconst reMonthlz = \u0027(0[0-9]|1[0-2])\u0027\r\nconst reDay = \u0027(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)\u0027\r\nconst reDaylz = \u0027(0[0-9]|[1-2][0-9]|3[01])\u0027\r\nconst reMonthFull = \u0027january|february|march|april|may|june|july|august|september|october|november|december\u0027\r\nconst reMonthAbbr = \u0027jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec\u0027\r\nconst reMonthroman = \u0027i[vx]|vi{0,3}|xi{0,2}|i{1,3}\u0027\r\nconst reMonthText = \u0027(\u0027 \u002B reMonthFull \u002B \u0027|\u0027 \u002B reMonthAbbr \u002B \u0027|\u0027 \u002B reMonthroman \u002B \u0027)\u0027\r\nconst reTzCorrection = \u0027((?:GMT)?([\u002B-])\u0027 \u002B reHour24 \u002B \u0027:?\u0027 \u002B reMinute \u002B \u0027?)\u0027\r\nconst reTzAbbr = \u0027\\\\(?([a-zA-Z]{1,6})\\\\)?\u0027\r\nconst reDayOfYear = \u0027(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])\u0027\r\nconst reWeekOfYear = \u0027(0[1-9]|[1-4][0-9]|5[0-3])\u0027\r\nconst reDateNoYear = reMonthText \u002B \u0027[ .\\\\t-]*\u0027 \u002B reDay \u002B \u0027[,.stndrh\\\\t ]*\u0027\r\nfunction processMeridian (hour, meridian) {\r\n meridian = meridian \u0026\u0026 meridian.toLowerCase()\r\n switch (meridian) {\r\n case \u0027a\u0027:\r\n hour \u002B= hour === 12 ? -12 : 0\r\n break\r\n case \u0027p\u0027:\r\n hour \u002B= hour !== 12 ? 12 : 0\r\n break\r\n }\r\n return hour\r\n}\r\nfunction processYear (yearStr) {\r\n let year = \u002ByearStr\r\n if (yearStr.length \u003C 4 \u0026\u0026 year \u003C 100) {\r\n year \u002B= year \u003C 70 ? 2000 : 1900\r\n }\r\n return year\r\n}\r\nfunction lookupMonth (monthStr) {\r\n return {\r\n jan: 0,\r\n january: 0,\r\n i: 0,\r\n feb: 1,\r\n february: 1,\r\n ii: 1,\r\n mar: 2,\r\n march: 2,\r\n iii: 2,\r\n apr: 3,\r\n april: 3,\r\n iv: 3,\r\n may: 4,\r\n v: 4,\r\n jun: 5,\r\n june: 5,\r\n vi: 5,\r\n jul: 6,\r\n july: 6,\r\n vii: 6,\r\n aug: 7,\r\n august: 7,\r\n viii: 7,\r\n sep: 8,\r\n sept: 8,\r\n september: 8,\r\n ix: 8,\r\n oct: 9,\r\n october: 9,\r\n x: 9,\r\n nov: 10,\r\n november: 10,\r\n xi: 10,\r\n dec: 11,\r\n december: 11,\r\n xii: 11\r\n }[monthStr.toLowerCase()]\r\n}\r\nfunction lookupWeekday (dayStr, desiredSundayNumber = 0) {\r\n const dayNumbers = {\r\n mon: 1,\r\n monday: 1,\r\n tue: 2,\r\n tuesday: 2,\r\n wed: 3,\r\n wednesday: 3,\r\n thu: 4,\r\n thursday: 4,\r\n fri: 5,\r\n friday: 5,\r\n sat: 6,\r\n saturday: 6,\r\n sun: 0,\r\n sunday: 0\r\n }\r\n return dayNumbers[dayStr.toLowerCase()] || desiredSundayNumber\r\n}\r\nfunction lookupRelative (relText) {\r\n const relativeNumbers = {\r\n last: -1,\r\n previous: -1,\r\n this: 0,\r\n first: 1,\r\n next: 1,\r\n second: 2,\r\n third: 3,\r\n fourth: 4,\r\n fifth: 5,\r\n sixth: 6,\r\n seventh: 7,\r\n eight: 8,\r\n eighth: 8,\r\n ninth: 9,\r\n tenth: 10,\r\n eleventh: 11,\r\n twelfth: 12\r\n }\r\n const relativeBehavior = {\r\n this: 1\r\n }\r\n const relTextLower = relText.toLowerCase()\r\n return {\r\n amount: relativeNumbers[relTextLower],\r\n behavior: relativeBehavior[relTextLower] || 0\r\n }\r\n}\r\nfunction processTzCorrection (tzOffset, oldValue) {\r\n const reTzCorrectionLoose = /(?:GMT)?([\u002B-])(\\d\u002B)(:?)(\\d{0,2})/i\r\n tzOffset = tzOffset \u0026\u0026 tzOffset.match(reTzCorrectionLoose)\r\n if (!tzOffset) {\r\n return oldValue\r\n }\r\n const sign = tzOffset[1] === \u0027-\u0027 ? -1 : 1\r\n let hours = \u002BtzOffset[2]\r\n let minutes = \u002BtzOffset[4]\r\n if (!tzOffset[4] \u0026\u0026 !tzOffset[3]) {\r\n minutes = Math.floor(hours % 100)\r\n hours = Math.floor(hours / 100)\r\n }\r\n // timezone offset in seconds\r\n return sign * (hours * 60 \u002B minutes) * 60\r\n}\r\n// tz abbrevation : tz offset in seconds\r\nconst tzAbbrOffsets = {\r\n acdt: 37800,\r\n acst: 34200,\r\n addt: -7200,\r\n adt: -10800,\r\n aedt: 39600,\r\n aest: 36000,\r\n ahdt: -32400,\r\n ahst: -36000,\r\n akdt: -28800,\r\n akst: -32400,\r\n amt: -13840,\r\n apt: -10800,\r\n ast: -14400,\r\n awdt: 32400,\r\n awst: 28800,\r\n awt: -10800,\r\n bdst: 7200,\r\n bdt: -36000,\r\n bmt: -14309,\r\n bst: 3600,\r\n cast: 34200,\r\n cat: 7200,\r\n cddt: -14400,\r\n cdt: -18000,\r\n cemt: 10800,\r\n cest: 7200,\r\n cet: 3600,\r\n cmt: -15408,\r\n cpt: -18000,\r\n cst: -21600,\r\n cwt: -18000,\r\n chst: 36000,\r\n dmt: -1521,\r\n eat: 10800,\r\n eddt: -10800,\r\n edt: -14400,\r\n eest: 10800,\r\n eet: 7200,\r\n emt: -26248,\r\n ept: -14400,\r\n est: -18000,\r\n ewt: -14400,\r\n ffmt: -14660,\r\n fmt: -4056,\r\n gdt: 39600,\r\n gmt: 0,\r\n gst: 36000,\r\n hdt: -34200,\r\n hkst: 32400,\r\n hkt: 28800,\r\n hmt: -19776,\r\n hpt: -34200,\r\n hst: -36000,\r\n hwt: -34200,\r\n iddt: 14400,\r\n idt: 10800,\r\n imt: 25025,\r\n ist: 7200,\r\n jdt: 36000,\r\n jmt: 8440,\r\n jst: 32400,\r\n kdt: 36000,\r\n kmt: 5736,\r\n kst: 30600,\r\n lst: 9394,\r\n mddt: -18000,\r\n mdst: 16279,\r\n mdt: -21600,\r\n mest: 7200,\r\n met: 3600,\r\n mmt: 9017,\r\n mpt: -21600,\r\n msd: 14400,\r\n msk: 10800,\r\n mst: -25200,\r\n mwt: -21600,\r\n nddt: -5400,\r\n ndt: -9052,\r\n npt: -9000,\r\n nst: -12600,\r\n nwt: -9000,\r\n nzdt: 46800,\r\n nzmt: 41400,\r\n nzst: 43200,\r\n pddt: -21600,\r\n pdt: -25200,\r\n pkst: 21600,\r\n pkt: 18000,\r\n plmt: 25590,\r\n pmt: -13236,\r\n ppmt: -17340,\r\n ppt: -25200,\r\n pst: -28800,\r\n pwt: -25200,\r\n qmt: -18840,\r\n rmt: 5794,\r\n sast: 7200,\r\n sdmt: -16800,\r\n sjmt: -20173,\r\n smt: -13884,\r\n sst: -39600,\r\n tbmt: 10751,\r\n tmt: 12344,\r\n uct: 0,\r\n utc: 0,\r\n wast: 7200,\r\n wat: 3600,\r\n wemt: 7200,\r\n west: 3600,\r\n wet: 0,\r\n wib: 25200,\r\n wita: 28800,\r\n wit: 32400,\r\n wmt: 5040,\r\n yddt: -25200,\r\n ydt: -28800,\r\n ypt: -28800,\r\n yst: -32400,\r\n ywt: -28800,\r\n a: 3600,\r\n b: 7200,\r\n c: 10800,\r\n d: 14400,\r\n e: 18000,\r\n f: 21600,\r\n g: 25200,\r\n h: 28800,\r\n i: 32400,\r\n k: 36000,\r\n l: 39600,\r\n m: 43200,\r\n n: -3600,\r\n o: -7200,\r\n p: -10800,\r\n q: -14400,\r\n r: -18000,\r\n s: -21600,\r\n t: -25200,\r\n u: -28800,\r\n v: -32400,\r\n w: -36000,\r\n x: -39600,\r\n y: -43200,\r\n z: 0\r\n}\r\nconst formats = {\r\n yesterday: {\r\n regex: /^yesterday/i,\r\n name: \u0027yesterday\u0027,\r\n callback () {\r\n this.rd -= 1\r\n return this.resetTime()\r\n }\r\n },\r\n now: {\r\n regex: /^now/i,\r\n name: \u0027now\u0027\r\n // do nothing\r\n },\r\n noon: {\r\n regex: /^noon/i,\r\n name: \u0027noon\u0027,\r\n callback () {\r\n return this.resetTime() \u0026\u0026 this.time(12, 0, 0, 0)\r\n }\r\n },\r\n midnightOrToday: {\r\n regex: /^(midnight|today)/i,\r\n name: \u0027midnight | today\u0027,\r\n callback () {\r\n return this.resetTime()\r\n }\r\n },\r\n tomorrow: {\r\n regex: /^tomorrow/i,\r\n name: \u0027tomorrow\u0027,\r\n callback () {\r\n this.rd \u002B= 1\r\n return this.resetTime()\r\n }\r\n },\r\n timestamp: {\r\n regex: /^@(-?\\d\u002B)/i,\r\n name: \u0027timestamp\u0027,\r\n callback (match, timestamp) {\r\n this.rs \u002B= \u002Btimestamp\r\n this.y = 1970\r\n this.m = 0\r\n this.d = 1\r\n this.dates = 0\r\n return this.resetTime() \u0026\u0026 this.zone(0)\r\n }\r\n },\r\n firstOrLastDay: {\r\n regex: /^(first|last) day of/i,\r\n name: \u0027firstdayof | lastdayof\u0027,\r\n callback (match, day) {\r\n if (day.toLowerCase() === \u0027first\u0027) {\r\n this.firstOrLastDayOfMonth = 1\r\n } else {\r\n this.firstOrLastDayOfMonth = -1\r\n }\r\n }\r\n },\r\n backOrFrontOf: {\r\n regex: RegExp(\u0027^(back|front) of \u0027 \u002B reHour24 \u002B reSpaceOpt \u002B reMeridian \u002B \u0027?\u0027, \u0027i\u0027),\r\n name: \u0027backof | frontof\u0027,\r\n callback (match, side, hours, meridian) {\r\n const back = side.toLowerCase() === \u0027back\u0027\r\n let hour = \u002Bhours\r\n let minute = 15\r\n if (!back) {\r\n hour -= 1\r\n minute = 45\r\n }\r\n hour = processMeridian(hour, meridian)\r\n return this.resetTime() \u0026\u0026 this.time(hour, minute, 0, 0)\r\n }\r\n },\r\n weekdayOf: {\r\n regex: RegExp(\u0027^(\u0027 \u002B reReltextnumber \u002B \u0027|\u0027 \u002B reReltexttext \u002B \u0027)\u0027 \u002B reSpace \u002B \u0027(\u0027 \u002B reDayfull \u002B \u0027|\u0027 \u002B reDayabbr \u002B \u0027)\u0027 \u002B reSpace \u002B \u0027of\u0027, \u0027i\u0027),\r\n name: \u0027weekdayof\u0027\r\n // todo\r\n },\r\n mssqltime: {\r\n regex: RegExp(\u0027^\u0027 \u002B reHour12 \u002B \u0027:\u0027 \u002B reMinutelz \u002B \u0027:\u0027 \u002B reSecondlz \u002B \u0027[:.]([0-9]\u002B)\u0027 \u002B reMeridian, \u0027i\u0027),\r\n name: \u0027mssqltime\u0027,\r\n callback (match, hour, minute, second, frac, meridian) {\r\n return this.time(processMeridian(\u002Bhour, meridian), \u002Bminute, \u002Bsecond, \u002Bfrac.substr(0, 3))\r\n }\r\n },\r\n timeLong12: {\r\n regex: RegExp(\u0027^\u0027 \u002B reHour12 \u002B \u0027[:.]\u0027 \u002B reMinute \u002B \u0027[:.]\u0027 \u002B reSecondlz \u002B reSpaceOpt \u002B reMeridian, \u0027i\u0027),\r\n name: \u0027timelong12\u0027,\r\n callback (match, hour, minute, second, meridian) {\r\n return this.time(processMeridian(\u002Bhour, meridian), \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n timeShort12: {\r\n regex: RegExp(\u0027^\u0027 \u002B reHour12 \u002B \u0027[:.]\u0027 \u002B reMinutelz \u002B reSpaceOpt \u002B reMeridian, \u0027i\u0027),\r\n name: \u0027timeshort12\u0027,\r\n callback (match, hour, minute, meridian) {\r\n return this.time(processMeridian(\u002Bhour, meridian), \u002Bminute, 0, 0)\r\n }\r\n },\r\n timeTiny12: {\r\n regex: RegExp(\u0027^\u0027 \u002B reHour12 \u002B reSpaceOpt \u002B reMeridian, \u0027i\u0027),\r\n name: \u0027timetiny12\u0027,\r\n callback (match, hour, meridian) {\r\n return this.time(processMeridian(\u002Bhour, meridian), 0, 0, 0)\r\n }\r\n },\r\n soap: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027-\u0027 \u002B reMonthlz \u002B \u0027-\u0027 \u002B reDaylz \u002B \u0027T\u0027 \u002B reHour24lz \u002B \u0027:\u0027 \u002B reMinutelz \u002B \u0027:\u0027 \u002B reSecondlz \u002B reFrac \u002B reTzCorrection \u002B \u0027?\u0027, \u0027i\u0027),\r\n name: \u0027soap\u0027,\r\n callback (match, year, month, day, hour, minute, second, frac, tzCorrection) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday) \u0026\u0026\r\n this.time(\u002Bhour, \u002Bminute, \u002Bsecond, \u002Bfrac.substr(0, 3)) \u0026\u0026\r\n this.zone(processTzCorrection(tzCorrection))\r\n }\r\n },\r\n wddx: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027-\u0027 \u002B reMonth \u002B \u0027-\u0027 \u002B reDay \u002B \u0027T\u0027 \u002B reHour24 \u002B \u0027:\u0027 \u002B reMinute \u002B \u0027:\u0027 \u002B reSecond),\r\n name: \u0027wddx\u0027,\r\n callback (match, year, month, day, hour, minute, second) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday) \u0026\u0026 this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n exif: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027:\u0027 \u002B reMonthlz \u002B \u0027:\u0027 \u002B reDaylz \u002B \u0027 \u0027 \u002B reHour24lz \u002B \u0027:\u0027 \u002B reMinutelz \u002B \u0027:\u0027 \u002B reSecondlz, \u0027i\u0027),\r\n name: \u0027exif\u0027,\r\n callback (match, year, month, day, hour, minute, second) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday) \u0026\u0026 this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n xmlRpc: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B reMonthlz \u002B reDaylz \u002B \u0027T\u0027 \u002B reHour24 \u002B \u0027:\u0027 \u002B reMinutelz \u002B \u0027:\u0027 \u002B reSecondlz),\r\n name: \u0027xmlrpc\u0027,\r\n callback (match, year, month, day, hour, minute, second) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday) \u0026\u0026 this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n xmlRpcNoColon: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B reMonthlz \u002B reDaylz \u002B \u0027[Tt]\u0027 \u002B reHour24 \u002B reMinutelz \u002B reSecondlz),\r\n name: \u0027xmlrpcnocolon\u0027,\r\n callback (match, year, month, day, hour, minute, second) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday) \u0026\u0026 this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n clf: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDay \u002B \u0027/(\u0027 \u002B reMonthAbbr \u002B \u0027)/\u0027 \u002B reYear4 \u002B \u0027:\u0027 \u002B reHour24lz \u002B \u0027:\u0027 \u002B reMinutelz \u002B \u0027:\u0027 \u002B reSecondlz \u002B reSpace \u002B reTzCorrection, \u0027i\u0027),\r\n name: \u0027clf\u0027,\r\n callback (match, day, month, year, hour, minute, second, tzCorrection) {\r\n return this.ymd(\u002Byear, lookupMonth(month), \u002Bday) \u0026\u0026\r\n this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0) \u0026\u0026\r\n this.zone(processTzCorrection(tzCorrection))\r\n }\r\n },\r\n iso8601long: {\r\n regex: RegExp(\u0027^t?\u0027 \u002B reHour24 \u002B \u0027[:.]\u0027 \u002B reMinute \u002B \u0027[:.]\u0027 \u002B reSecond \u002B reFrac, \u0027i\u0027),\r\n name: \u0027iso8601long\u0027,\r\n callback (match, hour, minute, second, frac) {\r\n return this.time(\u002Bhour, \u002Bminute, \u002Bsecond, \u002Bfrac.substr(0, 3))\r\n }\r\n },\r\n dateTextual: {\r\n regex: RegExp(\u0027^\u0027 \u002B reMonthText \u002B \u0027[ .\\\\t-]*\u0027 \u002B reDay \u002B \u0027[,.stndrh\\\\t ]\u002B\u0027 \u002B reYear, \u0027i\u0027),\r\n name: \u0027datetextual\u0027,\r\n callback (match, month, day, year) {\r\n return this.ymd(processYear(year), lookupMonth(month), \u002Bday)\r\n }\r\n },\r\n pointedDate4: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDay \u002B \u0027[.\\\\t-]\u0027 \u002B reMonth \u002B \u0027[.-]\u0027 \u002B reYear4),\r\n name: \u0027pointeddate4\u0027,\r\n callback (match, day, month, year) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday)\r\n }\r\n },\r\n pointedDate2: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDay \u002B \u0027[.\\\\t]\u0027 \u002B reMonth \u002B \u0027\\\\.\u0027 \u002B reYear2),\r\n name: \u0027pointeddate2\u0027,\r\n callback (match, day, month, year) {\r\n return this.ymd(processYear(year), month - 1, \u002Bday)\r\n }\r\n },\r\n timeLong24: {\r\n regex: RegExp(\u0027^t?\u0027 \u002B reHour24 \u002B \u0027[:.]\u0027 \u002B reMinute \u002B \u0027[:.]\u0027 \u002B reSecond),\r\n name: \u0027timelong24\u0027,\r\n callback (match, hour, minute, second) {\r\n return this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n dateNoColon: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B reMonthlz \u002B reDaylz),\r\n name: \u0027datenocolon\u0027,\r\n callback (match, year, month, day) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday)\r\n }\r\n },\r\n pgydotd: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027\\\\.?\u0027 \u002B reDayOfYear),\r\n name: \u0027pgydotd\u0027,\r\n callback (match, year, day) {\r\n return this.ymd(\u002Byear, 0, \u002Bday)\r\n }\r\n },\r\n timeShort24: {\r\n regex: RegExp(\u0027^t?\u0027 \u002B reHour24 \u002B \u0027[:.]\u0027 \u002B reMinute, \u0027i\u0027),\r\n name: \u0027timeshort24\u0027,\r\n callback (match, hour, minute) {\r\n return this.time(\u002Bhour, \u002Bminute, 0, 0)\r\n }\r\n },\r\n iso8601noColon: {\r\n regex: RegExp(\u0027^t?\u0027 \u002B reHour24lz \u002B reMinutelz \u002B reSecondlz, \u0027i\u0027),\r\n name: \u0027iso8601nocolon\u0027,\r\n callback (match, hour, minute, second) {\r\n return this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n iso8601dateSlash: {\r\n // eventhough the trailing slash is optional in PHP\r\n // here it\u0027s mandatory and inputs without the slash\r\n // are handled by dateslash\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027/\u0027 \u002B reMonthlz \u002B \u0027/\u0027 \u002B reDaylz \u002B \u0027/\u0027),\r\n name: \u0027iso8601dateslash\u0027,\r\n callback (match, year, month, day) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday)\r\n }\r\n },\r\n dateSlash: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027/\u0027 \u002B reMonth \u002B \u0027/\u0027 \u002B reDay),\r\n name: \u0027dateslash\u0027,\r\n callback (match, year, month, day) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday)\r\n }\r\n },\r\n american: {\r\n regex: RegExp(\u0027^\u0027 \u002B reMonth \u002B \u0027/\u0027 \u002B reDay \u002B \u0027/\u0027 \u002B reYear),\r\n name: \u0027american\u0027,\r\n callback (match, month, day, year) {\r\n return this.ymd(processYear(year), month - 1, \u002Bday)\r\n }\r\n },\r\n americanShort: {\r\n regex: RegExp(\u0027^\u0027 \u002B reMonth \u002B \u0027/\u0027 \u002B reDay),\r\n name: \u0027americanshort\u0027,\r\n callback (match, month, day) {\r\n return this.ymd(this.y, month - 1, \u002Bday)\r\n }\r\n },\r\n gnuDateShortOrIso8601date2: {\r\n // iso8601date2 is complete subset of gnudateshort\r\n regex: RegExp(\u0027^\u0027 \u002B reYear \u002B \u0027-\u0027 \u002B reMonth \u002B \u0027-\u0027 \u002B reDay),\r\n name: \u0027gnudateshort | iso8601date2\u0027,\r\n callback (match, year, month, day) {\r\n return this.ymd(processYear(year), month - 1, \u002Bday)\r\n }\r\n },\r\n iso8601date4: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4withSign \u002B \u0027-\u0027 \u002B reMonthlz \u002B \u0027-\u0027 \u002B reDaylz),\r\n name: \u0027iso8601date4\u0027,\r\n callback (match, year, month, day) {\r\n return this.ymd(\u002Byear, month - 1, \u002Bday)\r\n }\r\n },\r\n gnuNoColon: {\r\n regex: RegExp(\u0027^t?\u0027 \u002B reHour24lz \u002B reMinutelz, \u0027i\u0027),\r\n name: \u0027gnunocolon\u0027,\r\n callback (match, hour, minute) {\r\n // this rule is a special case\r\n // if time was already set once by any preceding rule, it sets the captured value as year\r\n switch (this.times) {\r\n case 0:\r\n return this.time(\u002Bhour, \u002Bminute, 0, this.f)\r\n case 1:\r\n this.y = hour * 100 \u002B \u002Bminute\r\n this.times\u002B\u002B\r\n return true\r\n default:\r\n return false\r\n }\r\n }\r\n },\r\n gnuDateShorter: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027-\u0027 \u002B reMonth),\r\n name: \u0027gnudateshorter\u0027,\r\n callback (match, year, month) {\r\n return this.ymd(\u002Byear, month - 1, 1)\r\n }\r\n },\r\n pgTextReverse: {\r\n // note: allowed years are from 32-9999\r\n // years below 32 should be treated as days in datefull\r\n regex: RegExp(\u0027^\u0027 \u002B \u0027(\\\\d{3,4}|[4-9]\\\\d|3[2-9])-(\u0027 \u002B reMonthAbbr \u002B \u0027)-\u0027 \u002B reDaylz, \u0027i\u0027),\r\n name: \u0027pgtextreverse\u0027,\r\n callback (match, year, month, day) {\r\n return this.ymd(processYear(year), lookupMonth(month), \u002Bday)\r\n }\r\n },\r\n dateFull: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDay \u002B \u0027[ \\\\t.-]*\u0027 \u002B reMonthText \u002B \u0027[ \\\\t.-]*\u0027 \u002B reYear, \u0027i\u0027),\r\n name: \u0027datefull\u0027,\r\n callback (match, day, month, year) {\r\n return this.ymd(processYear(year), lookupMonth(month), \u002Bday)\r\n }\r\n },\r\n dateNoDay: {\r\n regex: RegExp(\u0027^\u0027 \u002B reMonthText \u002B \u0027[ .\\\\t-]*\u0027 \u002B reYear4, \u0027i\u0027),\r\n name: \u0027datenoday\u0027,\r\n callback (match, month, year) {\r\n return this.ymd(\u002Byear, lookupMonth(month), 1)\r\n }\r\n },\r\n dateNoDayRev: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027[ .\\\\t-]*\u0027 \u002B reMonthText, \u0027i\u0027),\r\n name: \u0027datenodayrev\u0027,\r\n callback (match, year, month) {\r\n return this.ymd(\u002Byear, lookupMonth(month), 1)\r\n }\r\n },\r\n pgTextShort: {\r\n regex: RegExp(\u0027^(\u0027 \u002B reMonthAbbr \u002B \u0027)-\u0027 \u002B reDaylz \u002B \u0027-\u0027 \u002B reYear, \u0027i\u0027),\r\n name: \u0027pgtextshort\u0027,\r\n callback (match, month, day, year) {\r\n return this.ymd(processYear(year), lookupMonth(month), \u002Bday)\r\n }\r\n },\r\n dateNoYear: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDateNoYear, \u0027i\u0027),\r\n name: \u0027datenoyear\u0027,\r\n callback (match, month, day) {\r\n return this.ymd(this.y, lookupMonth(month), \u002Bday)\r\n }\r\n },\r\n dateNoYearRev: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDay \u002B \u0027[ .\\\\t-]*\u0027 \u002B reMonthText, \u0027i\u0027),\r\n name: \u0027datenoyearrev\u0027,\r\n callback (match, day, month) {\r\n return this.ymd(this.y, lookupMonth(month), \u002Bday)\r\n }\r\n },\r\n isoWeekDay: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4 \u002B \u0027-?W\u0027 \u002B reWeekOfYear \u002B \u0027(?:-?([0-7]))?\u0027),\r\n name: \u0027isoweekday | isoweek\u0027,\r\n callback (match, year, week, day) {\r\n day = day ? \u002Bday : 1\r\n if (!this.ymd(\u002Byear, 0, 1)) {\r\n return false\r\n }\r\n // get day of week for Jan 1st\r\n let dayOfWeek = new Date(this.y, this.m, this.d).getDay()\r\n // and use the day to figure out the offset for day 1 of week 1\r\n dayOfWeek = 0 - (dayOfWeek \u003E 4 ? dayOfWeek - 7 : dayOfWeek)\r\n this.rd \u002B= dayOfWeek \u002B ((week - 1) * 7) \u002B day\r\n }\r\n },\r\n relativeText: {\r\n regex: RegExp(\u0027^(\u0027 \u002B reReltextnumber \u002B \u0027|\u0027 \u002B reReltexttext \u002B \u0027)\u0027 \u002B reSpace \u002B \u0027(\u0027 \u002B reReltextunit \u002B \u0027)\u0027, \u0027i\u0027),\r\n name: \u0027relativetext\u0027,\r\n callback (match, relValue, relUnit) {\r\n // todo: implement handling of \u0027this time-unit\u0027\r\n // eslint-disable-next-line no-unused-vars\r\n const { amount, behavior } = lookupRelative(relValue)\r\n switch (relUnit.toLowerCase()) {\r\n case \u0027sec\u0027:\r\n case \u0027secs\u0027:\r\n case \u0027second\u0027:\r\n case \u0027seconds\u0027:\r\n this.rs \u002B= amount\r\n break\r\n case \u0027min\u0027:\r\n case \u0027mins\u0027:\r\n case \u0027minute\u0027:\r\n case \u0027minutes\u0027:\r\n this.ri \u002B= amount\r\n break\r\n case \u0027hour\u0027:\r\n case \u0027hours\u0027:\r\n this.rh \u002B= amount\r\n break\r\n case \u0027day\u0027:\r\n case \u0027days\u0027:\r\n this.rd \u002B= amount\r\n break\r\n case \u0027fortnight\u0027:\r\n case \u0027fortnights\u0027:\r\n case \u0027forthnight\u0027:\r\n case \u0027forthnights\u0027:\r\n this.rd \u002B= amount * 14\r\n break\r\n case \u0027week\u0027:\r\n case \u0027weeks\u0027:\r\n this.rd \u002B= amount * 7\r\n break\r\n case \u0027month\u0027:\r\n case \u0027months\u0027:\r\n this.rm \u002B= amount\r\n break\r\n case \u0027year\u0027:\r\n case \u0027years\u0027:\r\n this.ry \u002B= amount\r\n break\r\n case \u0027mon\u0027: case \u0027monday\u0027:\r\n case \u0027tue\u0027: case \u0027tuesday\u0027:\r\n case \u0027wed\u0027: case \u0027wednesday\u0027:\r\n case \u0027thu\u0027: case \u0027thursday\u0027:\r\n case \u0027fri\u0027: case \u0027friday\u0027:\r\n case \u0027sat\u0027: case \u0027saturday\u0027:\r\n case \u0027sun\u0027: case \u0027sunday\u0027:\r\n this.resetTime()\r\n this.weekday = lookupWeekday(relUnit, 7)\r\n this.weekdayBehavior = 1\r\n this.rd \u002B= (amount \u003E 0 ? amount - 1 : amount) * 7\r\n break\r\n case \u0027weekday\u0027:\r\n case \u0027weekdays\u0027:\r\n // todo\r\n break\r\n }\r\n }\r\n },\r\n relative: {\r\n regex: RegExp(\u0027^([\u002B-]*)[ \\\\t]*(\\\\d\u002B)\u0027 \u002B reSpaceOpt \u002B \u0027(\u0027 \u002B reReltextunit \u002B \u0027|week)\u0027, \u0027i\u0027),\r\n name: \u0027relative\u0027,\r\n callback (match, signs, relValue, relUnit) {\r\n const minuses = signs.replace(/[^-]/g, \u0027\u0027).length\r\n const amount = \u002BrelValue * Math.pow(-1, minuses)\r\n switch (relUnit.toLowerCase()) {\r\n case \u0027sec\u0027:\r\n case \u0027secs\u0027:\r\n case \u0027second\u0027:\r\n case \u0027seconds\u0027:\r\n this.rs \u002B= amount\r\n break\r\n case \u0027min\u0027:\r\n case \u0027mins\u0027:\r\n case \u0027minute\u0027:\r\n case \u0027minutes\u0027:\r\n this.ri \u002B= amount\r\n break\r\n case \u0027hour\u0027:\r\n case \u0027hours\u0027:\r\n this.rh \u002B= amount\r\n break\r\n case \u0027day\u0027:\r\n case \u0027days\u0027:\r\n this.rd \u002B= amount\r\n break\r\n case \u0027fortnight\u0027:\r\n case \u0027fortnights\u0027:\r\n case \u0027forthnight\u0027:\r\n case \u0027forthnights\u0027:\r\n this.rd \u002B= amount * 14\r\n break\r\n case \u0027week\u0027:\r\n case \u0027weeks\u0027:\r\n this.rd \u002B= amount * 7\r\n break\r\n case \u0027month\u0027:\r\n case \u0027months\u0027:\r\n this.rm \u002B= amount\r\n break\r\n case \u0027year\u0027:\r\n case \u0027years\u0027:\r\n this.ry \u002B= amount\r\n break\r\n case \u0027mon\u0027: case \u0027monday\u0027:\r\n case \u0027tue\u0027: case \u0027tuesday\u0027:\r\n case \u0027wed\u0027: case \u0027wednesday\u0027:\r\n case \u0027thu\u0027: case \u0027thursday\u0027:\r\n case \u0027fri\u0027: case \u0027friday\u0027:\r\n case \u0027sat\u0027: case \u0027saturday\u0027:\r\n case \u0027sun\u0027: case \u0027sunday\u0027:\r\n this.resetTime()\r\n this.weekday = lookupWeekday(relUnit, 7)\r\n this.weekdayBehavior = 1\r\n this.rd \u002B= (amount \u003E 0 ? amount - 1 : amount) * 7\r\n break\r\n case \u0027weekday\u0027:\r\n case \u0027weekdays\u0027:\r\n // todo\r\n break\r\n }\r\n }\r\n },\r\n dayText: {\r\n regex: RegExp(\u0027^(\u0027 \u002B reDaytext \u002B \u0027)\u0027, \u0027i\u0027),\r\n name: \u0027daytext\u0027,\r\n callback (match, dayText) {\r\n this.resetTime()\r\n this.weekday = lookupWeekday(dayText, 0)\r\n if (this.weekdayBehavior !== 2) {\r\n this.weekdayBehavior = 1\r\n }\r\n }\r\n },\r\n relativeTextWeek: {\r\n regex: RegExp(\u0027^(\u0027 \u002B reReltexttext \u002B \u0027)\u0027 \u002B reSpace \u002B \u0027week\u0027, \u0027i\u0027),\r\n name: \u0027relativetextweek\u0027,\r\n callback (match, relText) {\r\n this.weekdayBehavior = 2\r\n switch (relText.toLowerCase()) {\r\n case \u0027this\u0027:\r\n this.rd \u002B= 0\r\n break\r\n case \u0027next\u0027:\r\n this.rd \u002B= 7\r\n break\r\n case \u0027last\u0027:\r\n case \u0027previous\u0027:\r\n this.rd -= 7\r\n break\r\n }\r\n if (isNaN(this.weekday)) {\r\n this.weekday = 1\r\n }\r\n }\r\n },\r\n monthFullOrMonthAbbr: {\r\n regex: RegExp(\u0027^(\u0027 \u002B reMonthFull \u002B \u0027|\u0027 \u002B reMonthAbbr \u002B \u0027)\u0027, \u0027i\u0027),\r\n name: \u0027monthfull | monthabbr\u0027,\r\n callback (match, month) {\r\n return this.ymd(this.y, lookupMonth(month), this.d)\r\n }\r\n },\r\n tzCorrection: {\r\n regex: RegExp(\u0027^\u0027 \u002B reTzCorrection, \u0027i\u0027),\r\n name: \u0027tzcorrection\u0027,\r\n callback (tzCorrection) {\r\n return this.zone(processTzCorrection(tzCorrection))\r\n }\r\n },\r\n tzAbbr: {\r\n regex: RegExp(\u0027^\u0027 \u002B reTzAbbr),\r\n name: \u0027tzabbr\u0027,\r\n callback (match, abbr) {\r\n const offset = tzAbbrOffsets[abbr.toLowerCase()]\r\n if (isNaN(offset)) {\r\n return false\r\n }\r\n return this.zone(offset)\r\n }\r\n },\r\n ago: {\r\n regex: /^ago/i,\r\n name: \u0027ago\u0027,\r\n callback () {\r\n this.ry = -this.ry\r\n this.rm = -this.rm\r\n this.rd = -this.rd\r\n this.rh = -this.rh\r\n this.ri = -this.ri\r\n this.rs = -this.rs\r\n this.rf = -this.rf\r\n }\r\n },\r\n year4: {\r\n regex: RegExp(\u0027^\u0027 \u002B reYear4),\r\n name: \u0027year4\u0027,\r\n callback (match, year) {\r\n this.y = \u002Byear\r\n return true\r\n }\r\n },\r\n whitespace: {\r\n regex: /^[ .,\\t]\u002B/,\r\n name: \u0027whitespace\u0027\r\n // do nothing\r\n },\r\n dateShortWithTimeLong: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDateNoYear \u002B \u0027t?\u0027 \u002B reHour24 \u002B \u0027[:.]\u0027 \u002B reMinute \u002B \u0027[:.]\u0027 \u002B reSecond, \u0027i\u0027),\r\n name: \u0027dateshortwithtimelong\u0027,\r\n callback (match, month, day, hour, minute, second) {\r\n return this.ymd(this.y, lookupMonth(month), \u002Bday) \u0026\u0026 this.time(\u002Bhour, \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n dateShortWithTimeLong12: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDateNoYear \u002B reHour12 \u002B \u0027[:.]\u0027 \u002B reMinute \u002B \u0027[:.]\u0027 \u002B reSecondlz \u002B reSpaceOpt \u002B reMeridian, \u0027i\u0027),\r\n name: \u0027dateshortwithtimelong12\u0027,\r\n callback (match, month, day, hour, minute, second, meridian) {\r\n return this.ymd(this.y, lookupMonth(month), \u002Bday) \u0026\u0026 this.time(processMeridian(\u002Bhour, meridian), \u002Bminute, \u002Bsecond, 0)\r\n }\r\n },\r\n dateShortWithTimeShort: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDateNoYear \u002B \u0027t?\u0027 \u002B reHour24 \u002B \u0027[:.]\u0027 \u002B reMinute, \u0027i\u0027),\r\n name: \u0027dateshortwithtimeshort\u0027,\r\n callback (match, month, day, hour, minute) {\r\n return this.ymd(this.y, lookupMonth(month), \u002Bday) \u0026\u0026 this.time(\u002Bhour, \u002Bminute, 0, 0)\r\n }\r\n },\r\n dateShortWithTimeShort12: {\r\n regex: RegExp(\u0027^\u0027 \u002B reDateNoYear \u002B reHour12 \u002B \u0027[:.]\u0027 \u002B reMinutelz \u002B reSpaceOpt \u002B reMeridian, \u0027i\u0027),\r\n name: \u0027dateshortwithtimeshort12\u0027,\r\n callback (match, month, day, hour, minute, meridian) {\r\n return this.ymd(this.y, lookupMonth(month), \u002Bday) \u0026\u0026 this.time(processMeridian(\u002Bhour, meridian), \u002Bminute, 0, 0)\r\n }\r\n }\r\n}\r\nconst resultProto = {\r\n // date\r\n y: NaN,\r\n m: NaN,\r\n d: NaN,\r\n // time\r\n h: NaN,\r\n i: NaN,\r\n s: NaN,\r\n f: NaN,\r\n // relative shifts\r\n ry: 0,\r\n rm: 0,\r\n rd: 0,\r\n rh: 0,\r\n ri: 0,\r\n rs: 0,\r\n rf: 0,\r\n // weekday related shifts\r\n weekday: NaN,\r\n weekdayBehavior: 0,\r\n // first or last day of month\r\n // 0 none, 1 first, -1 last\r\n firstOrLastDayOfMonth: 0,\r\n // timezone correction in minutes\r\n z: NaN,\r\n // counters\r\n dates: 0,\r\n times: 0,\r\n zones: 0,\r\n // helper functions\r\n ymd (y, m, d) {\r\n if (this.dates \u003E 0) {\r\n return false\r\n }\r\n this.dates\u002B\u002B\r\n this.y = y\r\n this.m = m\r\n this.d = d\r\n return true\r\n },\r\n time (h, i, s, f) {\r\n if (this.times \u003E 0) {\r\n return false\r\n }\r\n this.times\u002B\u002B\r\n this.h = h\r\n this.i = i\r\n this.s = s\r\n this.f = f\r\n return true\r\n },\r\n resetTime () {\r\n this.h = 0\r\n this.i = 0\r\n this.s = 0\r\n this.f = 0\r\n this.times = 0\r\n return true\r\n },\r\n zone (minutes) {\r\n if (this.zones \u003C= 1) {\r\n this.zones\u002B\u002B\r\n this.z = minutes\r\n return true\r\n }\r\n return false\r\n },\r\n toDate (relativeTo) {\r\n if (this.dates \u0026\u0026 !this.times) {\r\n this.h = this.i = this.s = this.f = 0\r\n }\r\n // fill holes\r\n if (isNaN(this.y)) {\r\n this.y = relativeTo.getFullYear()\r\n }\r\n if (isNaN(this.m)) {\r\n this.m = relativeTo.getMonth()\r\n }\r\n if (isNaN(this.d)) {\r\n this.d = relativeTo.getDate()\r\n }\r\n if (isNaN(this.h)) {\r\n this.h = relativeTo.getHours()\r\n }\r\n if (isNaN(this.i)) {\r\n this.i = relativeTo.getMinutes()\r\n }\r\n if (isNaN(this.s)) {\r\n this.s = relativeTo.getSeconds()\r\n }\r\n if (isNaN(this.f)) {\r\n this.f = relativeTo.getMilliseconds()\r\n }\r\n // adjust special early\r\n switch (this.firstOrLastDayOfMonth) {\r\n case 1:\r\n this.d = 1\r\n break\r\n case -1:\r\n this.d = 0\r\n this.m \u002B= 1\r\n break\r\n }\r\n if (!isNaN(this.weekday)) {\r\n const date = new Date(relativeTo.getTime())\r\n date.setFullYear(this.y, this.m, this.d)\r\n date.setHours(this.h, this.i, this.s, this.f)\r\n const dow = date.getDay()\r\n if (this.weekdayBehavior === 2) {\r\n // To make \u0022this week\u0022 work, where the current day of week is a \u0022sunday\u0022\r\n if (dow === 0 \u0026\u0026 this.weekday !== 0) {\r\n this.weekday = -6\r\n }\r\n // To make \u0022sunday this week\u0022 work, where the current day of week is not a \u0022sunday\u0022\r\n if (this.weekday === 0 \u0026\u0026 dow !== 0) {\r\n this.weekday = 7\r\n }\r\n this.d -= dow\r\n this.d \u002B= this.weekday\r\n } else {\r\n let diff = this.weekday - dow\r\n // some PHP magic\r\n if ((this.rd \u003C 0 \u0026\u0026 diff \u003C 0) || (this.rd \u003E= 0 \u0026\u0026 diff \u003C= -this.weekdayBehavior)) {\r\n diff \u002B= 7\r\n }\r\n if (this.weekday \u003E= 0) {\r\n this.d \u002B= diff\r\n } else {\r\n this.d -= (7 - (Math.abs(this.weekday) - dow))\r\n }\r\n this.weekday = NaN\r\n }\r\n }\r\n // adjust relative\r\n this.y \u002B= this.ry\r\n this.m \u002B= this.rm\r\n this.d \u002B= this.rd\r\n this.h \u002B= this.rh\r\n this.i \u002B= this.ri\r\n this.s \u002B= this.rs\r\n this.f \u002B= this.rf\r\n this.ry = this.rm = this.rd = 0\r\n this.rh = this.ri = this.rs = this.rf = 0\r\n const result = new Date(relativeTo.getTime())\r\n // since Date constructor treats years \u003C= 99 as 1900\u002B\r\n // it can\u0027t be used, thus this weird way\r\n result.setFullYear(this.y, this.m, this.d)\r\n result.setHours(this.h, this.i, this.s, this.f)\r\n // note: this is done twice in PHP\r\n // early when processing special relatives\r\n // and late\r\n // todo: check if the logic can be reduced\r\n // to just one time action\r\n switch (this.firstOrLastDayOfMonth) {\r\n case 1:\r\n result.setDate(1)\r\n break\r\n case -1:\r\n result.setMonth(result.getMonth() \u002B 1, 0)\r\n break\r\n }\r\n // adjust timezone\r\n if (!isNaN(this.z) \u0026\u0026 result.getTimezoneOffset() !== this.z) {\r\n result.setUTCFullYear(\r\n result.getFullYear(),\r\n result.getMonth(),\r\n result.getDate())\r\n result.setUTCHours(\r\n result.getHours(),\r\n result.getMinutes(),\r\n result.getSeconds() - this.z,\r\n result.getMilliseconds())\r\n }\r\n return result\r\n }\r\n}\r\nfunction strtotime (str, now) {\r\n // discuss at: https://locutus.io/php/strtotime/\r\n // original by: Caio Ariede (https://caioariede.com)\r\n // improved by: Kevin van Zonneveld (https://kvz.io)\r\n // improved by: Caio Ariede (https://caioariede.com)\r\n // improved by: A. Mat\u00EDas Quezada (https://amatiasq.com)\r\n // improved by: preuter\r\n // improved by: Brett Zamir (https://brett-zamir.me)\r\n // improved by: Mirko Faber\r\n // input by: David\r\n // bugfixed by: Wagner B. Soares\r\n // bugfixed by: Artur Tchernychev\r\n // bugfixed by: Stephan B\u00F6sch-Plepelits (https://github.com/plepe)\r\n // reimplemented by: Rafa\u0142 Kukawski\r\n // note 1: Examples all have a fixed timestamp to prevent\r\n // note 1: tests to fail because of variable time(zones)\r\n // example 1: strtotime(\u0027\u002B1 day\u0027, 1129633200)\r\n // returns 1: 1129719600\r\n // example 2: strtotime(\u0027\u002B1 week 2 days 4 hours 2 seconds\u0027, 1129633200)\r\n // returns 2: 1130425202\r\n // example 3: strtotime(\u0027last month\u0027, 1129633200)\r\n // returns 3: 1127041200\r\n // example 4: strtotime(\u00272009-05-04 08:30:00\u002B00\u0027)\r\n // returns 4: 1241425800\r\n // example 5: strtotime(\u00272009-05-04 08:30:00\u002B02:00\u0027)\r\n // returns 5: 1241418600\r\n // example 6: strtotime(\u00272009-05-04 08:30:00 YWT\u0027)\r\n // returns 6: 1241454600\r\n if (now == null) {\r\n now = Math.floor(Date.now() / 1000)\r\n }\r\n // the rule order is important\r\n // if multiple rules match, the longest match wins\r\n // if multiple rules match the same string, the first match wins\r\n const rules = [\r\n formats.yesterday,\r\n formats.now,\r\n formats.noon,\r\n formats.midnightOrToday,\r\n formats.tomorrow,\r\n formats.timestamp,\r\n formats.firstOrLastDay,\r\n formats.backOrFrontOf,\r\n // formats.weekdayOf, // not yet implemented\r\n formats.timeTiny12,\r\n formats.timeShort12,\r\n formats.timeLong12,\r\n formats.mssqltime,\r\n formats.timeShort24,\r\n formats.timeLong24,\r\n formats.iso8601long,\r\n formats.gnuNoColon,\r\n formats.iso8601noColon,\r\n formats.americanShort,\r\n formats.american,\r\n formats.iso8601date4,\r\n formats.iso8601dateSlash,\r\n formats.dateSlash,\r\n formats.gnuDateShortOrIso8601date2,\r\n formats.gnuDateShorter,\r\n formats.dateFull,\r\n formats.pointedDate4,\r\n formats.pointedDate2,\r\n formats.dateNoDay,\r\n formats.dateNoDayRev,\r\n formats.dateTextual,\r\n formats.dateNoYear,\r\n formats.dateNoYearRev,\r\n formats.dateNoColon,\r\n formats.xmlRpc,\r\n formats.xmlRpcNoColon,\r\n formats.soap,\r\n formats.wddx,\r\n formats.exif,\r\n formats.pgydotd,\r\n formats.isoWeekDay,\r\n formats.pgTextShort,\r\n formats.pgTextReverse,\r\n formats.clf,\r\n formats.year4,\r\n formats.ago,\r\n formats.dayText,\r\n formats.relativeTextWeek,\r\n formats.relativeText,\r\n formats.monthFullOrMonthAbbr,\r\n formats.tzCorrection,\r\n formats.tzAbbr,\r\n formats.dateShortWithTimeShort12,\r\n formats.dateShortWithTimeLong12,\r\n formats.dateShortWithTimeShort,\r\n formats.dateShortWithTimeLong,\r\n formats.relative,\r\n formats.whitespace\r\n ]\r\n const result = Object.create(resultProto)\r\n while (str.length) {\r\n let longestMatch = null\r\n let finalRule = null\r\n for (let i = 0, l = rules.length; i \u003C l; i\u002B\u002B) {\r\n const format = rules[i]\r\n const match = str.match(format.regex)\r\n if (match) {\r\n if (!longestMatch || match[0].length \u003E longestMatch[0].length) {\r\n longestMatch = match\r\n finalRule = format\r\n }\r\n }\r\n }\r\n if (!finalRule || (finalRule.callback \u0026\u0026 finalRule.callback.apply(result, longestMatch) === false)) {\r\n return false\r\n }\r\n str = str.substr(longestMatch[0].length)\r\n finalRule = null\r\n longestMatch = null\r\n }\r\n return Math.floor(result.toDate(new Date(now * 1000)) / 1000)\r\n}\r\n\r\nfunction parse(v) {\r\n return Date.parse(v);\r\n}\r\n","TestCases":[{"Name":"strtotime","Code":"strtotime(\u00272008-12-31\u0027);","IsDeferred":false},{"Name":"parse","Code":"parse(\u00272008-12-31\u0027);","IsDeferred":false}]}