summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/datetime/idate.js.map
blob: 2ffdefc3026a1b9fe350b3c7a6739c22c3540720 (plain) (blame)
1
{"version":3,"sources":["../../../src/php/datetime/idate.js"],"names":["module","exports","idate","format","timestamp","undefined","Error","length","_date","Date","a","Math","floor","getUTCHours","getUTCMinutes","getUTCSeconds","getDate","getHours","getMinutes","getFullYear","UTC","getMonth","getSeconds","round","getTime","getDay","parseInt","slice","getTimezoneOffset"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,KAAT,CAAgBC,MAAhB,EAAwBC,SAAxB,EAAmC;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAID,WAAWE,SAAf,EAA0B;AACxB,UAAM,IAAIC,KAAJ,CAAU,+CAAV,CAAN;AACD;AACD,MAAI,CAACH,OAAOI,MAAR,IAAkBJ,OAAOI,MAAP,GAAgB,CAAtC,EAAyC;AACvC,UAAM,IAAID,KAAJ,CAAU,0BAAV,CAAN;AACD;;AAED;AACA,MAAIE,QAAS,OAAOJ,SAAP,KAAqB,WAAtB,GACR,IAAIK,IAAJ,EADQ,GAEPL,qBAAqBK,IAAtB,GACE,IAAIA,IAAJ,CAASL,SAAT,CADF,GAEE,IAAIK,IAAJ,CAASL,YAAY,IAArB,CAJN;AAKA,MAAIM,CAAJ;;AAEA,UAAQP,MAAR;AACE,SAAK,GAAL;AACE,aAAOQ,KAAKC,KAAL,CAAW,CACfJ,MAAMK,WAAN,KAAsB,IAAvB,GACCL,MAAMM,aAAN,KAAwB,EADzB,GAEAN,MAAMO,aAAN,EAFA,GAEwB,IAHR,IAId,IAJG,IAIK,GAJZ;AAKF,SAAK,GAAL;AACE,aAAOP,MAAMQ,OAAN,EAAP;AACF,SAAK,GAAL;AACE,aAAOR,MAAMS,QAAN,KAAmB,EAAnB,IAAyB,EAAhC;AACF,SAAK,GAAL;AACE,aAAOT,MAAMS,QAAN,EAAP;AACF,SAAK,GAAL;AACE,aA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,CAAClB,MAAMW,WAAN,KAAsB,EAAvB,EACfQ,KADe,CACT,CADS,CAAT,EACI,EADJ,CAAP,CA5CJ,CA6CmB;AACjB,SAAK,GAAL;AACE,aAAOnB,MAAMW,WAAN,EAAP;AACF,SAAK,GAAL;AACE,aAAOR,KAAKC,KAAL,CAAW,CAACJ,QAAQ,IAAIC,IAAJ,CAASD,MAAMW,WAAN,EAAT,EAA8B,CAA9B,EAAiC,CAAjC,CAAT,IAAgD,KAA3D,CAAP;AACF,SAAK,GAAL;AACE,aAAO,CAACX,MAAMoB,iBAAN,EAAD,GAA6B,EAApC;AACF;AACE,YAAM,IAAItB,KAAJ,CAAU,iCAAV,CAAN;AArDJ;AAuDD,CAjFD","file":"idate.js","sourcesContent":["module.exports = function idate (format, timestamp) {\n  //  discuss at: http://locutus.io/php/idate/\n  // original by: Brett Zamir (http://brett-zamir.me)\n  // original by: date\n  // original by: gettimeofday\n  //    input by: Alex\n  // bugfixed by: Brett Zamir (http://brett-zamir.me)\n  // improved by: Theriault (https://github.com/Theriault)\n  //   example 1: idate('y', 1255633200)\n  //   returns 1: 9\n\n  if (format === undefined) {\n    throw new Error('idate() expects at least 1 parameter, 0 given')\n  }\n  if (!format.length || format.length > 1) {\n    throw new Error('idate format is one char')\n  }\n\n  // @todo: Need to allow date_default_timezone_set() (check for $locutus.default_timezone and use)\n  var _date = (typeof timestamp === 'undefined')\n    ? new Date()\n    : (timestamp instanceof Date)\n      ? new Date(timestamp)\n      : new Date(timestamp * 1000)\n  var a\n\n  switch (format) {\n    case 'B':\n      return Math.floor((\n        (_date.getUTCHours() * 36e2) +\n        (_date.getUTCMinutes() * 60) +\n        _date.getUTCSeconds() + 36e2\n      ) / 86.4) % 1e3\n    case 'd':\n      return _date.getDate()\n    case 'h':\n      return _date.getHours() % 12 || 12\n    case 'H':\n      return _date.getHours()\n    case 'i':\n      return _date.getMinutes()\n    case 'I':\n    // capital 'i'\n    // Logic original by getimeofday().\n    // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.\n    // If they are not equal, then DST is observed.\n      a = _date.getFullYear()\n      return 0 + (((new Date(a, 0)) - Date.UTC(a, 0)) !== ((new Date(a, 6)) - Date.UTC(a, 6)))\n    case 'L':\n      a = _date.getFullYear()\n      return (!(a & 3) && (a % 1e2 || !(a % 4e2))) ? 1 : 0\n    case 'm':\n      return _date.getMonth() + 1\n    case 's':\n      return _date.getSeconds()\n    case 't':\n      return (new Date(_date.getFullYear(), _date.getMonth() + 1, 0))\n      .getDate()\n    case 'U':\n      return Math.round(_date.getTime() / 1000)\n    case 'w':\n      return _date.getDay()\n    case 'W':\n      a = new Date(\n        _date.getFullYear(),\n        _date.getMonth(),\n        _date.getDate() - (_date.getDay() || 7) + 3\n      )\n      return 1 + Math.round((a - (new Date(a.getFullYear(), 0, 4))) / 864e5 / 7)\n    case 'y':\n      return parseInt((_date.getFullYear() + '')\n      .slice(2), 10) // This function returns an integer, unlike _date()\n    case 'Y':\n      return _date.getFullYear()\n    case 'z':\n      return Math.floor((_date - new Date(_date.getFullYear(), 0, 1)) / 864e5)\n    case 'Z':\n      return -_date.getTimezoneOffset() * 60\n    default:\n      throw new Error('Unrecognized _date format token')\n  }\n}\n"]}